I'm wanting to dynamically populate a switchee value, I've tried using an embed, but it seems the parse order means this won't work so I'm looking for aternative ideas, this is the code we've tried:

{exp:switchee variable="{segment_1}" parse="inward"}

    {case value="{embed='site/_school-list'}"}

    {case default="yes"}
        Otherwise go here   


Basically I want to automatically pull out all of the entries from the school channel and get their {url_title}, then check it against {segment_1}.

The code in the embed is:

{exp:channel:entries channel="schools" dynamic="no" limit="99999"}{url_title}|{/exp:channel:entries}

Which is outputting correctly when tested.

Any ideas?

1 Answer 1


While you could easily use Stash to pass the entry ids as a variable, you shouldn't.

To create the variable would mean iterating over the entire list of entries in a channel. That's expensive just for a simple routing operation.

Assuming this is being run on your site's default index template, and you have strict 404s disabled, why not just redirect if segment_1 exists at all?

{if segment_1 != ""}

Your template contribute/school should take care of 404s using a channel entries tag with parameters require_entry="yes" and {if no_results}{redirect="404"}{/if}

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.