0

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

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 $data 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?

4

As I told you earlier today, this is not a Low Search issue, but a conditionals parsing issue. If you turn on Template Debugging, you'll see the opening tag just before it is actually executed. It will look something like this:

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

That is what's executed, and what EE uses to set the internal ee()->TMPL->tagparams array, which in turn is used by Low Search.

But if you change the tag to a native Channel Entries tag, you will see the same effect; ie. the unparsed conditional.

Turns out that if an embed variable isn't set, that conditional is treated as an advanced conditional, and therefore parsed after the tags, making them unsuitable to use to set/hide parameters like that.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.