6 users online. Create an account or sign in to join them.Users
Advanced Symphony Search?
This is an open discussion with 26 replies, filed under Troubleshooting.
Search
I just realized that ?parameter1=somevalue¶meter1=othervalue filters only by the latter value (only this value is assigned to the $url-parameter1). Is this the default or I've done something wrong in my setup?
Regarding the OR logic, I discovered this thread and after implementing it, the $url-parameter1 is set with comma separated values (in the parameter pool). However, I can't seem to output it correctly in the url. I get: ?parameter1[]=somevalue¶meter1[]=othervalue.
UPDATE: I noticed that even if I get ?parameter1[]=somevalue¶meter1[]=othervalue in the url, the filter works correctly with OR logic.
Regarding the AND logic, I am modifying Marco's event to use plus sign, instead of a comma. This one works correctly, too.
Now, to let the user choose which logic to use, I have added a select field in the form and based on its value I have to choose how to join the parameter values.
Could you give me a hand with the PHP? I have written this in the __trigger() function of the event:
if ($_GET[$this->withAll] = "no") {
$page->_param['url-'. $this->elementName] = join(',', $_GET[$this->elementName]);
}
if ($_GET[$this->withAll] = "yes") {
$page->_param['url-'. $this->elementName] = join('+', $_GET[$this->elementName]);
}
but with either value of the select field (widthAll) it returns the + join.
I've probably not written the if statement correctly, because if I use the event with only one of the join function (either) it works as it is supposed to.
I appreciate your help!
Try == instead of =. (It's a comparison, so you need a comparison operator.)
Thanks, Michael.
I changed = to ==.
I also fixed the two if statements, now using else if.
But I think the real culprit was that I had declared the variable that holds the yes/no value outside the __trigger function (public $widthAll = 'search_all';). But now I have it inside the trigger:
protected function __trigger(){
$page = Frontend::instance()->Page();
$widthAll = $_GET['search_all'];
if ($widthAll == "yes") {
$page->_param['url-'. $this->elementName] = join('+', $_GET[$this->elementName]);
}
else if ($widthAll == "no") {
$page->_param['url-'. $this->elementName] = join(',', $_GET[$this->elementName]);
}
}
and it works correctly. Thanks a lot for helping.
You are welcome, ellie. Looks like you already build some really cool features into your Symphony projects! :-)
Well, thank you, Michael! I truly enjoy myself, Symphony is amazing! It's incredible how many possibilities it offers depending on how you use the "simple" tools it gives you.
I wish I could show you how the search module is coming out. Using nickdunn's Search Index, alpacaa's custom event, carsten's dynamic sorting and lots of thread reading in here, I am pretty sure it will beat the site's competitors on search functionalities!
Create an account or sign in to comment.
No, nothing to do with the other thread. A completely different project.
This one must have a very advanced seacrh and regarding this parameter, my idea will be to allow the user decide whether to use the AND logic or OR. But for now I am not even able to get the OR logic...
By the way, if I manually write
?parameter1=somevalue,othervaluein the url it works as expected (OR).