1

Using Stash 2.3.6, EE 2.5.5, Playa 4.3.3...

I want to stash a list of related playa entries for Model1. I want to assign the variables for Model2 based on my Model2 embed.

See {!-- THIS IS NOT BEING SET --} below:

If I manually assign variables with {exp:stash:set} within the playa loop, the code works fine. It is the nested embed that is failing.

Anyone have any advice for me? I love the way the code is laid out, and I want to keep it DRY.

Main landing page (EE template)

{stash:embed:layout:main}

{exp:stash:parse}
    {exp:channel:entries
        channel       = "list"
        limit         = "1"
        require_entry = "yes"
    }
        {if no_results}{redirect="404"}{/if}
        {stash:embed:model:model1 process="start"}
    {/exp:channel:entries}
{/exp:stash:parse}

{exp:stash:content}
    {exp:stash:get_list name="list_of_related_model2" process="end"}
        <li>{title} - {url_title}</li>
    {/exp:stash:get_list}
{/exp:stash:content}

Model 1 (stash template)

{exp:stash:set name="title"}{title}{/exp:stash:set}

{exp:stash:set_list name="list_of_related_model2" parse_tags="yes"}
    {exp:playa:children field="cf_related"}
        {stash:embed:model:model2 process="start"}{!-- THIS IS NOT BEING SET --}
    {/exp:playa:children}
{/exp:stash:set_list}

Model 2 (stash template)

{exp:stash:set name="title"}{title}{/exp:stash:set}
{exp:stash:set name="url_title"}{url_title}{/exp:stash:set}
1

The first thing I'd suggest is that Model 2 should be a snippet. Capturing the standard entry fields (title, url_title, entry_id etc) is something I tend to do repeatedly in my viewModels, and I use a snippet called {set_standard} to do it so I don't repeat myself. The other issue here is that process="start" is relative to the processing of the root EE embed, NOT the immediate parent template of the embed (in Stash 2.3.6). As the embed is nested EE is already at the 'inline' phase of processing. Thus to get the above working would require including the embed in the root template (with output="no" so it doesn't display) and then referencing it as a placeholder {stash:model2} in the child template.

| improve this answer | |
  • Thanks for the tip, I will give it a try and post back how it works out – Benjamin Smith May 18 '13 at 15:44

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.