search multiple data in one field filter

I can't think of a simple way of doing it, at the moment.

We do allow for multiple search values, but only via the Advanced Search feature, or query string filters.

So to build something using a simple textarea, and busting the search up from each line of input, would require a custom page with it's own form, that then created the necessary query string filters to build the "OR" based search.

-- hugh
 
Hi Hugh,

Thanks for your reply ...

Yes, I think i should create a custom search form with redirect plugin.

This is what i did so far :

1)create a form ( record in database =no)
2)create a textarea element (___searchqform)
3)use redirect plugin

at jump page i insert this :

?view=list&listid=3&qform_sampel___sampel_noqform[value][]={___searchqform}&qform_sampel___sampel_noqform[value][]={___searchqform}&qform_sampel___sampel_noqform[join]=OR

im stuck on how to ectract or separated multiple string value in textarea element.
do i need to use explode () and return array data ? - im not really good in PHP and need some advice ...

Thanks
 
Yeah, that's kind of where I got stuck in my previous answer.

The only way I can think of is kind of kludgy, but it might work. You'd have to set a max limit on the number of search items (like 10). Then create 10 hidden field element, like search_1 through search_10. Set the default on each one to some random string that won't ever appear in the data you are searching, like no_data.

Add a PHP form plugin, running onBeforeProcess. In the PHP box, do this:

PHP:
$search_num = 1;
foreach (explode('\n', $formModel->_formData['___searchqform']) as $search_term)
{
   $search_field = '___search_' . $search_num;
   $formModel->updateFormData($search_field, $search_term, true, true);
   $search_num++;
   if ($search_num > 10)
   {
      break;
   }
}

This should bust up your textarea and put each line into one of the ___search_X elements.

Then in your redirect, instead of using {___searchqform}, put 10 search terms, for ___search_1 through ___search_10.

This will end up with any 'unused' ones searching for your non-existent default text, but ... should work.

Like I said, kind of kludgy, but should work.

-- hugh
 
Thanks hugh,

base on your solution i try to reduce the hidden elements with created only one calc element which will be used at jump url. so far the code is working but i dont know whether my code is good or not.

here is what i put at calc element :

PHP:
$text_line = "{___searchqform}";
$text_line = explode(",",$text_line);

$jumpurl ="";
for ($start=0;$start<count($text_line) ;$start++) 
{
    if ($start >= 5)
    {
       break;
    }

     $jumpurl.="&qform_sampel___sampel_noqform[value][]=" . $text_line[$start] ;
 }
return $jumpurl;

The problem is when i use "\n" in $text_line = explode("\n",$text_line); , the url will get only one the first data ..
 
Just to confirm, you are generating the input as one search term per line in the textarea, correct? So they are separated by a newline?

And you definitely use "\n" not '\n' as the first argument to explode?

-- hugh
 
Actually im planning tu use separated by comma or enter (new line as search term) ...

Yes i used "\n" ... as i remembered , when i use '\n' , it gave no result ...
 
Tested this in PHP submission plugin, where it gives me the array split by newline:

Code:
$text_line = "{test___text}";
$text_line = explode("\n",$text_line);
var_dump($text_line);exit;
 
Thanks Greif,

I end up to use only 1 delimiter , newline "\n".
I used explode ("\r\n",$text_line") and it's working.

Thanks again.
 
One more thing,

Currently I have successfully search multiple values using redirect plugin+custom search form.

This is the URL for my redirect page/list :

..index.php?option=com_fabrik&view=list&listid=3&Itemid=101&qform_sampel___sampel_noqform[value][]=PDPA0012&qform_sampel___sampel_noqform[value][]=PDPA0031&qform_sampel___sampel_noqform[join]=OR

My Question:

1) How to hide or encrypt this URL ? I think I should not expose the url and it's not secure. am I right ?

2) Is it possible to use this custom form in module or content plugin so that I can call/filter the list using ajax?


Thanks
 
1) I don't think there's any issues with exposing that URL. You are just using user input to generate a search term, so there's nothing they could do knowing the URL that they couldn't do by putting text in your input box. You might could possibly make it a POST rather than a get, but then the args would still be exposed to anyone who cared to look, in the page headers.

If you are concerned about users accessing rows they shouldn't, that needs to be handled within Fabrik, with whatever combination of pre-filters and ACL's makes sense for your usage.

2) Should be. Have you tried?

-- hugh
 
Hi Hugh, Thanks.

Ok I'll ignore about the URL.

What should i put into jump URL if i want to redirect the result to the module or content plugin ?

I already tried using fabrik form module , but i can search one time only
 
Hi,
to be clear i have successfully insert below code into jump page url:

index.php?option=com_fabrik&view=list&listid=3&Itemid=101&qform_sampel___sampel_noqform[value][]=PDPA0012&qform_sampel___sampel_noqform[value][]=PDPA0031&qform_sampel___sampel_noqform[join]=OR

I can get the result but i want to display the filtered list in a module.
So i created a fabrik list module.

the problem is the list are displayed in container and also in the fabrik module.

so i need advise how should i redirect the custom search form to a module position.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top