0

So, I have a scenario where I'm setting a Stash variable based on a query string being passed. I'm using Mo' Variables to get the $_GET values.

// Query string: /?c1=74&c2=81

{exp:ifelse parse="inward" parse_tags="yes"}
{if get:c1}
  {exp:stash:set name="active_cat" parse_tags="yes"}{get:c1}{/exp:stash:set}
  {/if}

  {if get:c2}
  {exp:stash:set name="active_cat" parse_tags="yes"}{get:c2}{/exp:stash:set}
  {/if}

  {if get:c3}
  {exp:stash:set name="active_cat" parse_tags="yes"}{get:c3}{/exp:stash:set}
  {/if}

  {if get:c4}
  {exp:stash:set name="active_cat" parse_tags="yes"}{get:c4}{/exp:stash:set}
  {/if}
{/exp:ifelse}

Works directly: {exp:stash:get name="c2" dynamic="yes"}<br> // outputs 81
Stash Variable works: {exp:stash:get name="active_cat" process="end"} // outputs 81

{exp:channel:entries 
    channel="{stash:_channel}" 
    category="{exp:stash:get name='active_cat' process='end'}"
    dynamic="no" 
    orderby="title" 
    sort="asc" 
    limit="10" 
    parse="inward"
    status="{stash:_status}"
    disable="member_data|pagination"
}
    <li><a href="{structure:page_url_for:{entry_id}}">{stash:_channel} - {stash:_status} - {title}</a></li>
{/exp:channel:entries}

Basically, it assigns a Stash variable 'active_cat' to c1, c2, etc. If a "c4" exists though, it overwrites that variable with the new value.

It works outside of the channel entries loop, but isn't being passed into the channel entries loop. This is in a Stash embed and there are 2 other variables passed into the loop correctly from the parent template.

1 Answer 1

0

So, it seems that I have to wrap the channel entries tag pair inside of {exp:stash:parse process="end"}, and then remove the process='end' from the active_cat tag being passed as a parameter.

{exp:stash:parse process="end"}
{exp:channel:entries 
    channel="{stash:_channel}" 
    category="{exp:stash:active_cat}"
    dynamic="no" 
    orderby="title" 
    sort="asc" 
    limit="10" 
    parse="inward"
    status="{stash:_status}"
    disable="member_data|pagination"
}
    <li><a href="{structure:page_url_for:{entry_id}}">{title}</a></li>
{/exp:channel:entries}
{/exp:stash:parse}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.