1

I'm using Stash 2.3.6 beta. Can somebody explain why this works:

{exp:stash:set name="var1"}no{/exp:stash:set}
{exp:stash:set name="var1"}yes{/exp:stash:set}
{exp:stash:get name="var1"}

Where I get "yes" as output.

But this does not:

{exp:stash:set name="var1"}no{/exp:stash:set}
{exp:channel:entries channel="promos" limit="1"}
    {exp:stash:set name="var1" replace="yes"}yes{/exp:stash:set}
{/exp:channel:entries}
{exp:stash:get name="var1"}

Where I get "no" as output, but expect "yes".

I'm guessing it has to do with the parse order, and that channel:entries happens after everything outside of it is parsed. I looked at the parse order docs (The Template Engine), and it looks like channel:entries are processed on step 15, module and plugin tags. Not sure where Stash gets processed.

But, speaking of which, I did try adding process="end" to the get. That got me a funky looking output: {357b280a38bad6479603b312799efcb0422985159}

Any help appreciated.

4
  • I don't have the ability to test this right now, but i imagine you would want to set {exp:stash:set name="var1"}no{/exp:stash:set} to {exp:stash:set replace="yes" name="var1"}no{/exp:stash:set} – philecker Apr 10 '13 at 22:42
  • Yeah, I've actually already tried that @philecker. Still no go. Thanks though. – NotoriousWebmaster Apr 10 '13 at 22:55
  • Have you tried wrapping your channel entries with exp:stash:set – philecker Apr 11 '13 at 1:14
  • What's the main goal of overwriting the same variable exactly? I see what you're trying to do but can't understand why as I don't know the use case. – Ian Apr 12 '13 at 9:29
2

Such seemingly random strings can be a symptom of the Stash extension not being activated. Worth a check.

Those strings are used by Stash as placeholders getting replaced by the stash extension. If the stash extension is not activated, they never get replaced.

2
  • Important safety tip, boys and girls: read the installation instructions. (d'Oh!) Thanks @JeromeCoupe. – NotoriousWebmaster Apr 12 '13 at 13:12
  • Glad it worked for you. We've all been there – Jérôme Coupé Apr 17 '13 at 12:53
0

Yes, this is a parse order thing, the get is parsed before the second set, since it is within a channel entries tag pair. But this should work:

{exp:stash:set name="var1"}no{/exp:stash:set}

{exp:channel:entries limit="1"}
  {exp:stash:set name="var1" replace="yes"}yes{/exp:stash:set}
{/exp:channel:entries}

{exp:stash:parse process="end"}
  {exp:stash:get name="var1"}
{/exp:stash:parse}

But in general, you won't get very far with setting and getting data within the same template. That's why the template partials approach sets data in the base template and then gets it in an embedded template.

5
  • Thanks @aelvan. I tried exactly your code, and got this: {6ee64145dfa4ae5926a9c326266d5954317291731}. Any ideas? – NotoriousWebmaster Apr 11 '13 at 16:18
  • Works for me.. But I know that error, just can't remember what it's all about. :/ What version of PHP are you on? – aelvan Apr 11 '13 at 16:33
  • PHP 5.3.20. EE Core 2.5.5. – NotoriousWebmaster Apr 11 '13 at 16:39
  • 1
    Is the stash extension enabled ? – Jérôme Coupé Apr 11 '13 at 19:17
  • 1
    Yeah, the extension, that's it. :) Try it, NotoriousWebmaster. Been burnt by that myself. – aelvan Apr 12 '13 at 10:42

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.