croxton / Stash

Stash allows you to stash text and snippets of code for reuse throughout your templates.
GNU General Public License v3.0
197 stars 20 forks source link

Have to put "random" in all stash tags to prevent very weird results #129

Closed airways closed 9 years ago

airways commented 9 years ago

I am getting, well, basically random results from particularly {exp:stash:get} and {exp:stash:{varnname}} if I do NOT have "random" added to the tag:

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

There doesn't seem to be much mention of this in the docs, and it's fairly frustrating, somewhat limits stash's ability to help with reducing the amount of code and dumb-ness of a complex template.

croxton commented 9 years ago

EE caches identical tags, which can indeed have unexpected results if you change the value of the variable between instances of the tag - in loops, for example. You can use context="x" (where x is a unique value) when setting/getting a variable to give each instance a unique namespace. Or, you could consider using lists instead of variables.

If the value of your variable doesn't change then you can use it as a placeholder {stash:something} in Stash embeds. Or, if you prefer, set type="snippet" and access it like {something}. Either is more efficient than using a tag.