All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Embed variables aren't correctly parsed in the low search result parameters

arvinsim 27 Jun 2014 09:21 problem, rejected

I have this code for my low search results.


{exp:low_search:results
{if embed:author_id}author_id="{embed:author_id}"{/if}
...
{if embed:query}query="{embed:query}"{/if}
}
...


Seems simple enough. However, when I outputted the POST values in my
low_search_pre_search hook, I get this


array(
['embed:author_id}author_id'] =>
...
['embed:query}query'] =>
)


Why did it parse the parameters that way?

Replies

  1. Low 27 Jun 2014 09:27

    That isn't because of Low Search, but because of EE's template parser in general.

    If you must use conditionals like that, try changing the syntax to something like this:

    {if embed:author_id != ''}author_id="{embed:author_id}"{/if}


    In the case of these params, you can also just omit the conditionals, as the values will be ignored when empty.

  2. arvinsim 27 Jun 2014 10:10

    I did what you suggested, but I got this instead

    array(
    ...
    ['!'] =>
    ['}author_id'] =>
    ...

  3. Low 27 Jun 2014 10:14

    I fail to see how this is a Low Search issue. First of all, the way conditionals are handled is completely up to EE itself. Secondly, the low_search_pre_search hook shouldn't be using POST vars at all. It only uses the params which, again, are set by EE; just look at the ee()->TMPL->tagparams array.

    If the conditionals are causing parsing issues, try to work around them and remove them entirely when possible.

  4. arvinsim 27 Jun 2014 10:24

    So you are saying this is not a Low Search parsing issue? if so, I will report in StackExchange.

  5. Low 27 Jun 2014 10:28

    That's exactly what I'm saying. Those conditionals inside the opening tag aren't parsed by Low Search. They are parsed before any tags. Just enable the Template Debugger and look up the actual opening tags.