0

I'm putting together a sort of ViewModel-ish setup and getting strange output from {stash:nocache}

Here's the setup. First, the EE template:

{stash:embed
  context="@URI"
  file_name="viewmodels:detail"
  parse_stage="both"
  stash:_type="blog"
  stash:_layout="standard"
 }

viewmodels/detail.html

{stash:embed:layouts:{stash:_layout} priority="1"}

{stash:embed 
  file_name="viewmodels:detail:{stash:_type}"}

viewmodels/detail/blog.html

{exp:channel:entries [single entry parameters...]}

[SNIP store some other data, eg title, body…]

  {exp:stash:set_list name="post_links" parse_conditionals="yes" parse_tags="yes"}
    [SNIP some other items…]

    {stash:link}
      {if forum_topic}
        {path='forums/viewthread'}/{forum_topic_id}/
      {if:else}
        {stash:nocache}
          {if logged_in}
            {path='/forums/newtopic/18/'}
          {if:else}
            /forums/member/login/
          {/if}
        {/stash:nocache}
      {/if}
    {/stash:link}
    {stash:text}
      {if forum_topic}
        Discuss in the forums
      {if:else}
        {stash:nocache}
        {if logged_out}Log in and start{if:else}Start{/if} a discussion in the forums
        {/stash:nocache}
      {/if}
    {/stash:text}

  {/exp:stash:set_list}

{/exp:channel:entries}

layouts/standard.html

(part of it)

{exp:stash:get_list name="post_links"}
  <a href="{link}">{text}</a> <br/>
{/exp:stash:get_list}

All told, that outputs

<a href="[_Stash_1_SOMERANDOMLETTERSANDNUMBERS]">[_Stash_2_SOMERANDOMLETTERSANDNUMBERS]</a> <br/>

At first I thought it might an issue using {stash:nocache} within the {stash:KEY} elements of {exp:stash:set_list}, so I tried prefix="CUSTOM" on any/all of the {stash:embed}s and using {CUSTOM:nocache}, but that got me the same sort of garbled result. No combination of parse_stage="both" on any of the nested embeds seemed to make a difference either.

Extra weird, if I place the contents of viewmodels/detail/blog.html directly in 'viewmodels/detail.html' instead of the nested embed and just use {stash:nocache}, that works OK. So I could do that. But if anyone has any ideas why those list/{stash:nocache} elements are getting parsed that way so I could use the nested embed, that'd be useful.

0

Nevermind, looks like the issue was not having a distinct enough name for the stash list. "videos" was changed to "related_videos" and this solved the issue

| 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.