Extension, Module

Archived
Forum
(read-only)

Stash

ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6

Back to this add-on's main page
View Other Add-ons From Mark Croxton

     

Appending to list across multiple pages

Support Request

Ego Creative
Ego Creative

Hi Mark,

I’ve a question about an old thread on these forums:

https://devot-ee.com/add-ons/support/stash/viewthread/8734#29675

Is there a way to override the “safety” measure of save=“yes” across multiple page impressions?

I ask as I’d like to build up a list of entry data that’s persistant across pages…

For example page one would save to the list the data of entries: 1, 2, 3

And the page two would append to that list the data of entries: 4, 5, 6

After the impression of page two I would have a list that contained the data of entries: 1, 2, 3, 4, 5, 6

I’m using append list at the moment with no luck (I’m checking the var in Mustash).

Is that possible? Is that the right way of approaching it?

Thanks

Ego Creative
# 1
Ego Creative

Hold on, it’s just dawned on me that it’s probably better to save the entry data to individual stash variables, and maybe caching a list of ID’s for a “collection” of entries that. Purely for the caching issue of breaking one gigantic array.

I think I’ve answered my second question :)

Mark Croxton
# 2
Developer
Mark Croxton

The trick is to set a variable of the same name, and inside it get the old value. You can use unique=“yes” to avoid duplicates being added/output.

{exp:stash:set_list name="history" save="yes" scope="user" parse_tags="yes" replace="yes"}
   {exp
:stash:get_list name="history" scope="user" unique="yes"}
      {stash
:entry_id}{entry_id}{/stash:entry_id}
   {
/exp:stash:get_list}  
   {exp
:channel:entries limit="1"}
      {stash
:entry_id}{entry_id}{/stash:entry_id}
   {
/exp:channel:entries}
{
/exp:stash:set_list}

{exp
:stash:get_list name="history" scope="user" unique="yes" backspace="1"}{entry_id},{/exp:stash:get_list} 

Note that the scope is ‘user’ - i.e. unique to each user, which makes sense for something like a user’s page history.

Ego Creative
# 3
Ego Creative

That’s awesome to know - thanks Mark!

Grace Ruiz
# 4
Grace Ruiz

Here on your blog, the updates about express engine help would be quite updated. I admire your great update and hope able to get online with your further sharing. Would like to share the essayservice reviews with others to have further help please continue to share more updates here.