0

I have the following in a globally-included template:

{if segment_3_category_id}
  {exp:switchee variable="{segment_3}" parse="inward"}
    {case value="page-to-match"}
      {exp:stash:set_value
        name="st_surcharge"
        context="@URI"
        save="yes"
        scope="site"
        refresh="1440"
        value="TRUE"
      }
    {/case}
    {case default="Yes"}
      {exp:stash:set_value
        name="st_surcharge"
        context="@URI"
        save="yes"
        scope="site"
        refresh="1440"
        value="FALSE"
      }
    {/case}
  {/exp:switchee}
{/if}

{if segment_3 == "detail"}
  {exp:switchee variable="{segment_4}" parse="inward"}
    {case value="page-to-match"}
      {exp:stash:set_value
        name="st_surcharge"
        context="@URI"
        save="yes"
        scope="site"
        refresh="1440"
        value="TRUE"
      }
    {/case}
    {case default="Yes"}
      {exp:stash:set_value
        name="st_surcharge"
        context="@URI"
        save="yes"
        scope="site"
        refresh="1440"
        value="FALSE"
      }
    {/case}
  {/exp:switchee}
{/if}

In the template that has the segment_3_category_id if I do {if {exp:stash:get name="st_surcharge" context="@URI"} == "TRUE"} it works fine.

But in the template where segment_3=detail if I do the same thing, I get:

Something has gone wrong and this URL cannot be processed at this time.

A couple of other things I've tried are just outputting {exp:stash:get name="st_surcharge" context="@URI"} which gives me nothing and {exp:stash:get name="st_surcharge" context="@URI" process="end"} which returns either TRUE or FALSE depending on which page I'm on, which is expected.

If I put process="end" on the get statement inside the conditional, it always evaluates to FALSE.

I don't understand why one template is producing an error, but not the other. I can see the values for both templates being stored in the database.

3
  • 1
    You save the same content to the stash value "st_surcharge" whatever the qualifying values found are. So probably you could do this with a much simpler standard EE conditional statement that tests for the appropriate qualifying values and makes the assignment if right combinations are found Also, would be helpful to know what version of EE and Stash you are using... Mar 30 '20 at 10:51
  • EE 2.11.1 and Stash 2.6.9. The reason I went this route is because there's quite a lot of different values to check against so a standard conditional would look like {if a OR b OR c OR d OR e…}.
    – Tyssen
    Mar 30 '20 at 22:10
  • 1
    I ended up going your route after all. It's a bit messier coding-wise but kinda running out of time to get the fix up. Thanks!
    – Tyssen
    Mar 30 '20 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.