Plugin

Archived
Forum
(read-only)

Switchee

ExpressionEngine 1.x, ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4

Back to this add-on's main page
View Other Add-ons From Mark Croxton

     

Set Stash values from within {case}

Support Request

Matthew81
Matthew81

Is it possible to set Stash values from within a Switchee {case}?  It doesn’t seem to be working as follows:

{exp:switchee variable="{segment_3}" parse="inward"}
 {case value
="#.+#" default="Yes"}
  {exp
:stash:set name="catid" type="snippet" replace="no"}{segment_3_category_id}{/exp:stash:set}
 {
/case}
{
/exp:switchee}

{exp
:channel:entries channel="articles" limit="2" category="{catid}"}
 {title}
<br>
{/exp:channel:entries} 

Would love to be able to do this, as it would help me reduce the number of templates my site uses.

Thanks,

Matthew

Mark Croxton
# 1
Developer
Mark Croxton
{exp:stash:set parse_tags="yes"}
{exp
:switchee variable="{segment_3}" parse="inward"}
 {case value
="#.+#" default="Yes"}
  {stash
:catid}{segment_3_category_id}{/stash:catid}
 {
/case}
{
/exp:switchee}
{
/exp:stash:set}

{exp
:channel:entries 
  channel
="articles" 
  limit
="2" 
  category
="{exp:stash:get name='catid'}"
  
parse="inward"
}
 {title}
<br>
{/exp:channel:entries}