0

I am setting a list of entries added to a favorites list. Some of it works but the set_list portion doesn't. I cannot see why its not working.

{exp:shortlist:view}{exp:stash:append name='dofoco-favorites'}{entry_id}|{/exp:stash:append}{/exp:shortlist:view}

{exp:stash:set_list name='favorite_list'}
    {exp:channel:entries 
         status="not closed" 
         entry_id="{exp:stash:get name='dofoco-favorites' backspace='1'}|0" 
         dynamic="no" 
         parse="inward"
    }               
           {stash:favorite_thumbs}<li>{title}</li>{/stash:favorite_thumbs}                              
    {/exp:channel:entries}
{/exp:stash:set_list}

{exp:stash:get_list name='favorite_list'}{favorite_thumbs}{/exp:stash:get_list} 

However, this outputs as expected:

{exp:stash:set name="side-navigation"}
{exp:channel:entries
     status="not closed"         
     entry_id="{exp:stash:get name='dofoco-favorites' backspace='1'}|0" 
     dynamic="no"
     parse="inward"                                         
 }
    <li><a href="{page_url}">{title}</a></li>
{/exp:channel:entries}
{/exp:stash:set}

{exp:stash:get name="side-navigation"}
  • Does the list get created if you hard code entry ids into the channel entries tag? – since1976 Jan 24 '13 at 3:44
  • Hm. Yes the list does show when I hardcode. – Dan Johnson Jan 24 '13 at 4:38
4

There are two problems here. First, at the point you try to use dofoco-favorites it doesn't exist yet. Second, without using parse_tags="yes" when setting the list, the enclosed channel entries tag won't get parsed and the list won't be generated in order to be captured.

I keep banging on about peeling onions, but it's a helpful metaphor when thinking about how the EE template class parses module tags: from the outwards inwards, one layer of tags with each pass.

There are various ways to subvert parse order with Stash, but in this case the parse_tags="yes" parameter is the simplest. Using it you can parse any enclosed tags to whatever depth you like (determined by parse_depth="x").

{!-- capture the entry_ids, making sure the enclosed tag is fully parsed --}
{exp:stash:set name="dofoco-favorites" parse_tags="yes"}{exp:shortlist:view}{entry_id}|{/exp:shortlist:view}{/exp:stash:set}

{!-- capture the list items. We can access Stash vars like this {stash:my_var} --}
{exp:stash:set_list name="favorite_list" parse_tags="yes"}
    {exp:channel:entries 
         status="not closed" 
         entry_id="{stash:dofoco-favorites}0" 
         dynamic="no"
    }               
           {stash:favorite_thumbs}<li>{title}</li>{/stash:favorite_thumbs}                              
    {/exp:channel:entries}
{/exp:stash:set_list}

{exp:stash:get_list name="favorite_list"}
    {favorite_thumbs}
{/exp:stash:get_list} 
| improve this answer | |
0

Try adding parse_tags='yes' to your set_list parameters and removing parse='inward' from your channel entries tag.

| improve this answer | |
  • Tried with no luck. The list does show when I hardcode the entry_ids. – Dan Johnson Jan 24 '13 at 4:39
  • Try adding trim="yes" to your append:dofoco-favorites list – it'll remove any extraneous spaces. I;ve found when dealing with ID's empty spaces are a killer – stuartmcd69 Jan 24 '13 at 5:03

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.