Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The problem you are having comes down to the exp:channel:entries loop running multiple iterations, which then uses Stash to set an associative array of values. Once the channel:entries is compete, you have an array of {this_category_name} variables, so it's never actually set like a regular variable.</p> <p>So you really have a few options:</p> <ol> <li>Use a URI segment, since those are parsed early.</li> <li>Use the exp:stash:set tag to set a snippet type variable which can be parsed later on the page.</li> <li>Hardcode the values</li> </ol> <p>Here is my code, which I have tested and can confirm works 100% on my end. 1 caveat, if your entries have multiple categories this will break. I believe this will use the first category set within the iteration.</p> <p>Note, be sure to use the process="end" parameters to manipulate the parse order, otherwise you will end up with a blank screen.</p> <pre><code>{exp:channel:entries channel="your-channel" dynamic="no" disable="member_data|pagination"} {exp:stash:append_list name='list' parse_tags="yes" save="yes" scope="site" context='{categories}{category_name}{/categories}'} {stash:this_title}{title}{/stash:this_title} {categories} {stash:this_category_name} {category_name} {/stash:this_category_name} {exp:stash:set name="test_var" type="snippet"}{category_name}{/exp:stash:set} {/categories} {/exp:stash:append_list} {/exp:channel:entries} {exp:stash:parse process="end"} {exp:stash:get_list name="list" parse_tags="yes" parse_conditionals="yes" context="{test_var}" process="end"} &lt;div&gt; all my stash variables and html etc. &lt;/div&gt; {/exp:stash:get_list} {/exp:stash:parse} </code></pre> <p>I will add, that there is likely a much better way to tackle your problem. The logic of what you are trying to do doesn't really add up. I was merely attempting to answer your questions about Stash and if it <em>could</em> do it vs. being the best way.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload