0

If I understand correctly then I should be able to use Stash to set a variable on Template A and then retrieve it on Template B.

Template A contains

{exp:stash:set name="testvar" scope="site"}foo{/exp:stash:set}

Template B contains

Var= {exp:stash:get name="testvar" scope="site"}

There is nothing else on these templates but I don't get the value for testvar output on Template B.

2
  • did you try removing the scope=site from the stash:get? Feb 24, 2015 at 10:31
  • Yes. I have tried it without the scope parameter and also with scope set to "user"
    – foamcow
    Feb 24, 2015 at 10:35

1 Answer 1

1

If the 2 templates are not being used on the same page (via embed), try saving the stash variable so that it's stored in the database. Set refresh also for how long to store the variable.

{exp:stash:set 
    name="testvar" 
    scope="site"
    save="yes"
    refresh="60"
}
    foo
{/exp:stash:set}
2
  • That's looking promising actually. Did a quick test and it seems to work but I need to clear my head and test it properly! Thanks for the tip though.
    – foamcow
    Feb 24, 2015 at 15:26
  • If you do end up setting variables across the site or for users, it's a great benefit to pair Stash with Mustash to set cache breaking rules and clear the variable from the db at a variety of triggers: devot-ee.com/add-ons/mustash Feb 24, 2015 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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