3

Can I set the entry ids to the same stash name multiple times? ie, at one exp channel call , i will call exp:stash:set name='x'. Again I want the entry ids append to the same 'x' with another exp:channel:entries call. Is it possible?

It seems it's not working if we call exp:stash:set again.

My code:

{exp:stash:set  name="recently_viewed_ids" replace="yes" output="no" parse_tags="yes" trim="yes" append="yes"  }
  {exp:channel:entries channel="blog"  dynamic="no" backspace="1"  entry_id="not 26|24"}{entry_id}|{/exp:channel:entries}
{/exp:stash:set }

{exp:stash:get name='recently_viewed_ids'}{/exp:stash:get}

Outputs 23|22

{exp:stash:append name="recently_viewed_ids"  }
  {exp:channel:entries channel="business"  dynamic="no" backspace="1"  entry_id="8"}{entry_id}|{/exp:channel:entries}
{/exp:stash:append }

{exp:stash:get name='recently_viewed_ids'}{/exp:stash:get}

Outputs 23|22

Please help

1 Answer 1

2

The reason your output on the second get is the same is because of parse order. If you set that get to run later with process="end" it should show the combined result:

{exp:stash:set
    name="recently_viewed_ids" 
    parse_tags="yes" 
    trim="yes" 
}
  {exp:channel:entries channel="blog" dynamic="no" backspace="1"}{entry_id}|{/exp:channel:entries}
{/exp:stash:set}

Result 1: {exp:stash:get name='recently_viewed_ids'}

<hr>

{exp:stash:append 
    name="recently_viewed_ids"  
    parse_tags="yes"
    trim="yes"
}
  {exp:channel:entries channel="business" dynamic="no" backspace="1"}{entry_id}|{/exp:channel:entries}
{/exp:stash:append}

Result 2: {exp:stash:get name='recently_viewed_ids' process='end'}

Also, the first set doesn't need to be an append, and the second set needed a parse_tags parameter. The get also only needs a single tag not a tag pair, because it isn't set as a stash list.


UPDATE: Setting the ids as a list:

{exp:stash:set_list
    name="recently_viewed_ids"
    parse_tags="yes" 
}
    {stash:ids_1}{exp:channel:entries channel="CHANNEL_1" dynamic="no" backspace="1"}{entry_id}|{/exp:channel:entries}{/stash:ids_1}
    {stash:ids_2}{exp:channel:entries channel="CHANNEL_2" dynamic="no" backspace="1"}{entry_id}|{/exp:channel:entries}{/stash:ids_2}
    {stash:ids_3}{exp:channel:entries channel="CHANNEL_3" dynamic="no" backspace="1"}{entry_id}|{/exp:channel:entries}{/stash:ids_3}
{/exp:stash:set_list}

Result 1: {exp:stash:get_list name='recently_viewed_ids'}{ids_1}{/exp:stash:get_list}
<hr>
Result 2: {exp:stash:get_list name='recently_viewed_ids'}{ids_2}{/exp:stash:get_list}
<hr>
Result 3: {exp:stash:get_list name='recently_viewed_ids'}{ids_3}{/exp:stash:get_list}
<hr>
Result 1+2: {exp:stash:get_list name='recently_viewed_ids'}{ids_1}|{ids_2}{/exp:stash:get_list}
<hr>
Result 1+2+3: {exp:stash:get_list name='recently_viewed_ids'}{ids_1}|{ids_2}|{ids_3}{/exp:stash:get_list}
2
  • Thanks. But I cant give process="end" since I had to call exp:stash 3 or more times.Hope Process end will return only the final data. But I want all intermediate values. Can you please help how I can retrieve all intermediate values?
    – Dhanu
    Commented Nov 6, 2013 at 4:34
  • I'm not too sure of your overall purpose on the template you're working on, so just trying to answer the question as presented. But setting stash variables in a list might suit your needs better and give you more control over the combined ids, please see the updated example. Commented Nov 6, 2013 at 16:17

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.