1

Reading through James Smith's stash tutorial and would like a little extra info on the following example, '{stash:title}' is getting set after the embed template is added (in the page sequence at least), but it works, how?

{embed="site/head"}
{exp:stash:set name="extra-head-data"}
    <link href="special-css-just-for-this-view.css">
{/exp:stash:set}

{exp:stash:set name="extra-foot-data"}
    <script src="special-javascript-for-single-product-views.js"></script>
{/exp:stash:set}

{exp:channel:entries limit="1" channel="products"}
    {exp:stash:set parse_conditionals="yes"}
        {stash:title}{title}{/stash:title}
        {stash:meta-desc}
            {if summary}
                {summary}
            {if:else}
                {exp:eehive_hacksaw words="20"}{body}{/exp:eehive_hacksaw}
            {/if}
        {/stash:meta-desc}
    {/exp:stash:set}
    <h1>{title}</h1>
    {body}
{/exp:channel:entries}
{embed="site/foot"}
  • Could you clarify what your question is please? {stash:title} is getting set because you are setting it explicitly while looking at the first element in the "products" channel... but I am guessing that this is not your question. – jcogs.eecms Feb 5 '18 at 11:42
  • The embedded template 'site/head' is added before stash:title is set, stash:title is used in the 'site/head' template and is being resolved correctly, I guess the answer is that stash is called before embedding is done, it just doesn't seem intuitive and I thought embedding was done earlier in the parsing. – wot Feb 6 '18 at 19:59
3

If you want to understand parse order better, you could have a look at this handy cheat-sheet: originally created by Low, the copy on his site appears to have disappeared, but here is a version of it from another site.

https://www.cheatography.com/adrienne/cheat-sheets/ee-parse-order/

HTH

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.