1

I have the following tag that creates a simple search form:

{exp:search:simple_form channel="{exp:stash:get name='listing_channel'}" result_page="blog/search" no_result_page="blog/search" results="20" form_class="search" search_in="everywhere"}

I am trying to pass in the channel using the stash variable listing_channel from my template file - it is set to "blog". This tag only works if I add parse="inward". My understanding is that without parse="inward", the stash get tag would be parsed before the outer tag, which would result in the search form tag seeing channel="blog". I would think that this is what I would want, but yet it only works with parse="inward".

With parse="inward", wouldn't the stash variable be parsed after the search form tag? I would expect this to not work.

If someone with a better understanding could explain why parse="inward" is making this work, I'd really appreciate it!

Thanks!

2 Answers 2

2

Tags inside parameters aren't parsed at all unless you use parse="inward". That's because once parsed a tags' parameters are removed from the template (replaced with the output of the tag). Thus tags in parameters are never parsed.

The parse="inward" parameter tells EE to parse the other parameters passed to the parent tag before they are received by the tag's module code. Each parameter is parsed in turn (whether or not it has tags in it) so using it adds a small overhead to parsing.

5
  • Okay, that makes sense. The EE docs make it seem like parse="inward" is equivalent to telling EE "parse this tag before any module tags inside it", so this seems really counterintuitive to me since in this case parse="inward" essentially tells EE to parse the tags inside the parameters before this tag is parsed. Am I thinking about this correctly?
    – user7013
    Commented Jan 21, 2016 at 22:07
  • Also - in a situation where you need the parameters of an outer module tag to be parsed (so you need parse="inward"), but you want inner module tags to be parsed before the outer module tag (so you wouldn't want parse="inward"), what do you do? Seems like there should be a separate tag to tell EE to parse parameters. Or perhaps I'm thinking about things incorrectly.
    – user7013
    Commented Jan 21, 2016 at 22:17
  • "parse="inward" has another effect when applied to a plugin tag, causing it to be parsed before the tags it wraps (i.e. like a module tag does by default) - that is as well as parsing it's parameters. Commented Jan 22, 2016 at 10:35
  • Yes I agree it isn't particularly helpful to have the same parameter for both of these effects. parse="parameters" would be more logical. Commented Jan 22, 2016 at 10:37
  • The parse parameter seems to be a workaround (hack) to address a pretty glaring flaw in the templating engine. Passing a variable from into a function (tag) is such a basic requirement. EE should just handle this.
    – Henry
    Commented Sep 8, 2017 at 1:10
1

Here's another example that I hope will help others with similar confusion (as I was until about 15 minutes ago).

I was recently trying to get the following template to work:

{exp:app:voucher hash="{segment_3}"}
    {exp:pdf_press:parse_pdf filename="{product_url_title}-voucher.pdf"}
    <html>
        <body>
...
        </body>
    </html>
    {/exp:pdf_press:parse_pdf}
{/exp:app:voucher}

This code uses {exp:app:voucher} to parse the template and make a whole bunch of variables available including product_url_title. {exp:pdf_press:parse_pdf} then converts all the content inside to a PDF for download. I wanted to use product_url_title as part of the filename... unfortunately the out of the box behaviour produced this file name:

{product_url_title}-voucher.pdf.

So I tried parse="inward":

{exp:pdf_press:parse_pdf filename="{product_url_title}-voucher.pdf" parse="inward"}

Didn't help. Perhaps its "inwards":

{exp:pdf_press:parse_pdf filename="{product_url_title}-voucher.pdf" parse="inwards"}

Still didn't help... ( it is actually supposed to be parse="inward" btw)

I tried parse="outward" - nothing worked.

Finally I stumbled upon adding parse="inward" to the enclosing tag {exp:app:voucher}:

{exp:app:voucher hash="{segment_3}" parse="inward"}
    {exp:pdf_press:parse_pdf filename="{product_url_title}-voucher.pdf"}
    <html>
        <body>
...
        </body>
    </html>
    {/exp:pdf_press:parse_pdf}
{/exp:app:voucher}

So if you want to pass a variable to a tag add parse="inward" to the enclosing tag.

BUT, if you want to pass the result of another tag add parse="inward" to tag itself.

This is quite confusing, but looking at jws690's scenario {exp:search:simple_form} is an enclosing tag with respect to {exp:stash:get name='listing_channel'}.

Hope that helps someone...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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