This is my setup. My URL my-site/index.php/group/template-x

Template-x must call two different pieces of code. I want that to happen by using the third segment, which shall be NL or BE. So my-site/index.php/group/template-x/NL or my-site/index.php/group/template-x/BE.

The two pieces of code are stored as Stash Templates. The names are consumenten-NL.html and consumenten-BE.html. I can show the code by calling them hard coded, like {stash:embed:registration:consumenten-NL} but I want to use segment_3 dynamically.

In template-x I can grab segment-3.

{exp:stash:set name="segment-3"}{segment_3}{/exp:stash:set}

and show it in the template

{exp:stash:get name="segment-3"}

Now calling the embeds in template-x:, I do not seem to be able to do this:

{stash:embed:registration:consumenten-{exp:stash:get name="segment-3"}}


Stash: the file "../stash_templates/registration/consumenten-M40o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr.html" was not found.

I tried several other methods, but the documentation is too high for me, so I ask for a little assistance here. Much appreciated.


3 Answers 3


Maybe I've misunderstood, but why make segment_3 a stash variable? It's already an early-parsed global variable. Thus:

  • It has been a while since, and I forgot to complete this. Thanks, Mark, you made me think and we decided for a complete different setup. But the answer of Robson Sobral was very informative. I remembered his comment on another occasion, so thanks for that as well.
    – Hansl
    Jan 7, 2014 at 12:14

Is the both occurrences of {exp:stash:get name="segment-3"} on the same template? In this case, I know how to fix this.

This is a trick peculiarity of eecms template parser that sometimes bites us.

The template parser, when fount some tag to parse, looks for all another instances of the same tag, with the same parameters and the same content on the template and replaces every one of them by a temporary marker, to avoid to parse the same code more than once.

In your case, {exp:stash:get name="segment-3"} is being replaced by M40o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr. So:

{exp:stash:get name="segment-3"}
{stash:embed:registration:consumenten-{exp:stash:get name="segment-3"}}



Then, the parser founds {stash:embed:registration:consumenten-M40o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr} and replaces it by another marker.

In the time of parsing the first tag, its occurrence inside the second one isn't there yet, so it remains not parsed.

The solution is to prevent this "caching" on the second occurrence. Try this:

{stash:embed:registration:consumenten-{exp:stash:get name="segment-3" random}}

random is an undocumented parameter that sometimes saves the day. Just use it when you really need it!

You can read about it here, here and here.


You may just need to add process="end" to your stash embed tag:

{embed:stash:registration:consumenten-{exp:stash:get name="segment-3"} process="end"}


Two more options.

  1. Don't store segment_3 in stash since it's already a global variable. Use {segment_3} in your stash embed tag instead.

    {embed:stash:registration:consumenten-{segment_3} process="end"}

  2. Use set_value (docs) tag in template-x.

    {exp:stash:set_value name="segment-3" value="{segment_3}" parse="inward"} {embed:stash:registration:consumenten-{segment-3} process="end"}


Try putting double quotes around {segment_3} like this:

{embed:stash:registration:consumenten-"{segment_3}" process="end"}
{!-- OR without process parameter --}
  • I am sorry, unfortunately that does not help. Your code results in NL process="end"}
    – Hansl
    Oct 27, 2013 at 7:51
  • Thanks for thinking with me! I tried this before, {embed:stash:registration:consumenten-{segment_3} process="end"} it just returns NL (=value of segment_3. Now for {exp:stash:set_value name="segment-3" value="{segment_3}" parse="inward"} {embed:stash:registration:consumenten-{segment-3} process="end"} this results in NL process="end"}
    – Hansl
    Oct 27, 2013 at 8:29
  • What version of Stash do you have. Also, can you add to your original question what output you expect (what's in /consumenten-NL)? Oct 27, 2013 at 10:43

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.