I'm having a bit of trouble with getting Stash to change a variable. I'm using it to output a heading in search results when it's not the same as the last result. Here is my code:
{!-- Set the sorthead variable to something random --}
{exp:stash:set name="sorthead"}flibberdigibbet{/exp:stash:set}
{exp:low_search:results
channel="magazine-articles"
status="not closed"
limit="10"
paginate="both"
disable="member_data|category_fields"
category="1"
orderby="articles-sorthead"
sort="asc"
}
{!-- check the variable before setting --}
before: {exp:stash:get name='sorthead'}
{!-- output heading if it's not the same as the last one --}
{if "{exp:stash:get name='sorthead'}" != "{articles-sorthead}"}
<h2>{articles-sorthead}</h2>
{/if}
{!-- set the variable so that next time we can check again
THIS IS NOT HAPPENING FOR SOME REASON --}
{exp:stash:set name="sorthead"}{articles-sorthead}{/exp:stash:set}
{!-- check it has worked --}
after: {exp:stash:get name='sorthead'}
{/exp:low_search:results}
So I don't really know what is going on, but both before and after output as 'flibberdigibbet' and the setting never seems to happen the second time. unless the first set is happening on every loop of the low search tag - but I don't think it should be!
Hope you can help!