0

in the examples of Stash and every other similar plugin I always see the variables being set inside the channel:entries tag. But what if I need to set a tag inside the tag of another module? Like for example Solspace's Rating module? Have a look at the code below:

Here I'm trying to set a Stash variable...

{exp:rating:stats}
  {exp:stash:set name="rating"}{overall_rating}{/exp:stash:set}
{/exp:rating:stats}

Here I attempting to output it...

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

But this isn't working with Stash or the String plugin which I also tried.

It seems like I can only set variables inside the channel:entries tag. Is this true? Is there no way to store variables for later use inside third party module tags such as Solspace's Ratings?

0

Yes anything's possible when you get your head around parse order. There are several different ways of doing this, but generally I find it easiest to always put Stash on the outside of other tags (regardless of whether they're third party or not):

{exp:stash:set parse_tags="yes"}
    {exp:rating:stats}
        {stash:rating}{overall_rating}{/stash:rating}
        {stash:something-else}{another_thing}{/stash:something-else}
    {/exp:rating:stats}
{/exp:stash:set}

Rating: {exp:stash:get name="rating"}
  • Hi, I just played around with that code, but I can't get it to work. I will look into the getting a better understanding of the parse order though. – Jan Paul May 23 '13 at 13:23
  • Can you post more of your template? – James Smith May 23 '13 at 14:11
  • Played around a but more an got it working, thanks! :D – Jan Paul May 24 '13 at 2:10

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.