Selecting collection on search tag
Depending on a cookie value, I'd like to select the collection to draw my results from. So I have this code:
{exp:low_search:results query="{segment_3}"
collection="{if '{cookie}' == 'product'}products{if:else}blog{/if}"
status="open|{if '{cookie}' == 'product'}wide{if:else}featured{/if}"
}
But it's always coming up with a collection of products. Any ideas?
Replies
Low 24 Apr 2013 21:32
That's a parse order issue. The conditionals are advanced, and therefore parsed after tags. So when the tags are parsed, the parameter value contains the literal code.
To circumvent, install Mo Variables to get access to early parsed vars, including cookie vars.
Once installed, use simple conditionals only. You can use that in combination with preload replace vars for the parameters:
That's the logic to get the correct parameter values. Note that I'm not using {if:else}. The cookie:my_cookie vars should be available through Mo Variables.
Then, use this opening tag for the Results tag: