I'm trying to set (and change) a Stash var within a search loop. I tried process='end', parse='inward' and similar, but i can't set/update/replace the var inside the loop and get the proper value back:
{exp:search_fields search:chapter_keywords='{embed:search}' search:chapter_text='{embed:search}' operator="OR" channel="chapter" parse="inward"}
{exp:channel:entries entry_id="{search_results}" orderby="chapter_name" sort="asc" limit="50" dynamic="no" disable="categories|category_fields|member_data|pagination"}
{exp:stash:set name="chapterType" parse="inward" parse_tags="yes" trim="yes"}unknown{/exp:stash:set}
{chapter_videos limit="1"}
{if chapter_videos:count > 0}
{exp:stash:set name="chapterType" parse="inward" parse_tags="yes" trim="yes" replace="yes"}video{/exp:stash:set}
{/if}
{/chapter_videos}
{chapter_images limit="1"}
{if chapter_images:count > 0}
{exp:stash:set name="chapterType" parse="inward" parse_tags="yes" trim="yes" replace="yes"}image{/exp:stash:set}
{/if}
{/chapter_images}
{embed="_chapters/index" entryId="{entry_id}" chapterType="{exp:stash:get name='chapterType' process='end'}{/exp:stash:get}"}
Not closing exp: here, but they are closed for real.
{exp:stash:get name='chapterType' process='end'}{/exp:stash:get}
always returns 'image'
{exp:stash:get name='chapterType'}{/exp:stash:get}
always returns 'video'
When i output the chapterType within the loop without try to set it with Stash it'll print the correct vars (image, video, unknown) depending on the search results/loop entries.