I'm trying to create a stash variable of a pipe delimited entry_id list using the following:

{exp:channel:entries channel="related_entries" limit="1" disable="categories|member_data|pagination|trackbacks" entry_id="2249"}
{exp:stash:set name="featured_ids" parse_tags="yes"}
    {entry_relationships backspace="1" parse="inward"}{entry_id}|{/entry_relationships}


I've enabled template debugging and can see that the variable is being set by stash:

Stash: SET featured_ids to value 6147|8116|6270|3031|3019|463|6380

..but when I try and retrieve the variable using

{exp:stash:get name="featured_ids"}

I get

Stash: RETRIEVED featured_ids with value 

and looking at the order of the output, guess what? It is LATER in the parse order than setting the variable in the first place, which explains why it doesn't output anything.

Does anyone know how I can get around this?

EDIT: I've added process="end" to my get tag and now in the template debugging I'm seeing the following:

Stash: RETRIEVED featured_ids with value 6147|8116|6270|3031|3019|463|6380

but when I look at the output on the actual page, I'm seeing:


Anyone any ideas?



3 Answers 3


EDIT 1: Not that, see Mark's reply below for an in depth explanation

Might be an EE caching issue. If using the same tag more than once, try to add 'random' at the end of your get tag to stop EE from caching it.

{exp:stash:get name="featured_ids" random}

EDIT 2: tried to reproduce

Well, I tried on a sandbox install and the following code works

{exp:stash:set name="featured_ids" parse_tags="yes" trim="yes"}
    {exp:channel:entries disable="categories|category_fields|member_data|pagination|trackbacks" channel="news" status="open" dynamic="no" orderby="date" sort="desc" limit="500" backspace="1"}

{exp:stash:get name="featured_ids"}

So, I would try to move the set tags outside of the channel entries tags like so:

{exp:stash:set name="featured_ids" parse_tags="yes" trim="yes"}
    {exp:channel:entries channel="related_entries" limit="1" disable="categories|member_data|pagination|trackbacks" entry_id="2249"}
        {entry_relationships backspace="1"}{entry_id}|{/entry_relationships}

{exp:stash:get name="featured_ids"}

Any better ?

  • Thanks for that Jerome. However, I'm only calling the tag once. Commented Jan 17, 2013 at 14:47
  • Have you tried it? Because the long and seemingly random number you get instead of your entry ids looks like a problem I had recently. Adding random did solve it, although I was not using the tag multiple times. Commented Jan 17, 2013 at 14:52
  • I've tried it, yes. All I get is a different random looking string. Commented Jan 17, 2013 at 14:55
  • Well, had another idea after testing locally (albeit not with related entries). See above. Commented Jan 17, 2013 at 15:40
  • Glad it worked! Commented Jan 17, 2013 at 16:00

The original problem arises from the way that module tags are parsed by EE, from the outwards in. The outer layer of tags is parsed, then the next layer underneath, and so on: much like peeling an onion. In your case the {exp:channel:entries} tag and the {exp:stash:get} tag are on the outer layer, while the {exp:stash:set} is on the inner layer.

You tried to solve this, correctly, using process="end" parameter when you get the variable - but you saw a random string output. In this case it's NOT the famous M00.. string used as a cache placeholder by ExpressionEngine. Instead that string is a placeholder generated by Stash used to mark a position in the template for a variable; it gets replaced at the end of template processing by an extension triggered by the template_post_parse hook.

Of course, if you don't have the Stash extension installed then the placeholder never gets replaced and you see that string. So you simply need to install the extension :)

  • Hey Mark! Thanks for the in depth reply. Will try to remember that as a symptom of not installing the extension. Also, forgot to mention the now infamous oignon metaphor to explain how things are parsed. Commented Jan 17, 2013 at 21:20

Stash items like this are extemely sensitive to space/ing, try truncating your stash to one line and add trim="yes"

{exp:stash:set name="featured_ids" parse_tags="yes" trim="yes"}{entry_relationships backspace="1" parse="inward"}{entry_id}|{/entry_relationships}{/exp:stash:set}
  • Thanks for the tip Stuart. Sadly that hasn't made any difference. Do you know if there's a limit to the number of characters allowed in a stash variable? The number of entry_ids being stashed is actually around 500 rather than what I included in my post. Commented Jan 17, 2013 at 13:51
  • Try adding parse="inward" to your stash:set tag and remove from your entry_relationship Commented Jan 17, 2013 at 13:55
  • I've tried that and now immediately before the retrieve template debug line I'm getting this: Stash: post-processing tag: {exp:stash:get name="featured_ids" process="end"} will be replaced into {b0faccac1d7de314625221c018910507392912753} Commented Jan 17, 2013 at 14:16
  • add "random" to it? {exp:stash:get name="featured_ids" process="end" random} Commented Jan 17, 2013 at 14:32

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.