The problem you are facing boils down to an exp: channel: entries loop doing many iterations, which then uses Stash to set up an associative array of values. When the channel: records is competing, you have an array of variables {this_category_name}, so it is never set as a regular variable.
So you really have a few options:
- Use the URI segment as they are ranked earlier.
- Use the exp: stash: set parameter to set the fragment type variable, which can be analyzed later on the page.
- Hard code value
Here is my code that I tested and can confirm, works 100% at my end. 1 disclaimer, if your entries have several categories, this will break. I believe that this will use a set of the first category as part of the iteration.
Please note: do not forget to use the process = "end" parameters to control the parsing order, otherwise you will get a blank screen.
{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"} <div> all my stash variables and html etc. </div> {/exp:stash:get_list} {/exp:stash:parse}
I will add that there is probably a much better way to solve your problem. The logic of what you are trying to do does not really add up. I was just trying to answer your questions about Stash, and if that were possible, that would be the best way.
source share