Closed GDmac closed 11 years ago
No, the variables are saved correctly and respect the replace="no" parameter. I think your problem is you are not accessing the variables correctly:
This is incorrect:
{exp:stash:get name="stash:news_cat1_latest"}
This is correct:
{exp:stash:get name="news_cat1_latest"}
{!-- short-tag syntax --}
{exp:stash:news_cat1_latest}
{!-- in nested template only, or within block parsed by Stash only --}
{stash:news_cat1_latest}
ah, that was from copy-paste for re-creating the example. The problem is that when i turn template-debugging on, that channel:entries tags (or nested channel_images tags) still show up. e.g. it seems that the variables are not cached.
That's because the channel entries tag is outside the variable pairs that are captured. You can use a list instead of capturing multiple separate variables. This will behave like a single cached variable, in that the code wrapped by the list will not be subsequently run until the list cache expires.
{exp:stash:set_list name="my_list" parse_tags="yes" save="yes" replace="no" scope="site"}
// <!-- First get 1 entry from cat1, store the id and entry -->
{exp:channel:entries channel="news" dynamic="no" limit="1" category="1"}
{stash:news_cat1_id}{entry_id}{/stash:news_cat1_id}
{stash:news_cat1_latest}{title}{/stash:news_cat1_latest}
{/exp:channel:entries}
{/exp:stash:set_list}
{exp:stash:get_list name="my_list"}
{news_cat1_id}
{news_cat1_latest}
{/exp:stash:get_list}
It seems that exp:stash:set WITHOUT name= (e.g. with wrapped stash pairs) doesn't honor save=yes and replace=no somehow. Is this intended behaviour? if so, is there a way to save the wrapped variables?
(edit: the following example fetches two entries from a channel, each one from a particular category. It first fetches one entry from category-one and then one entry from category-two. Because an entry can be assigned to multiple categories, it is possible that the second channel:entries tag fetches the same entry. To fetch two unique entries, the first entry_id is fed into the second channel:entries tag to exclude that entry_id)
(edit: stash:get fixed for example)