3

I've got this code on a single entry template - it grabs the entry_id of the entry each time the template is loaded.

{exp:stash:set scope="user" save="yes" name="recently-viewed" replace="yes" parse_tags="yes"}{exp:stash:get name name="recently-viewed" scope="user"}{entry_id}|{/exp:stash:set}

In a another template I'm trying to use exp:channel:entries like this:

{exp:channel:entries entry_id="{exp:stash:get name='recently-viewed'}"}{title}{/exp:channel:entries}

I'm doing something wrong because no entries are being output by exp:channel:entries. If I use {exp:stash:get name="recently-viewed"} outside exp:channel:entries, I'm getting the expected output, e.g. 2883|7365|3837.

I've tried all day to figure it out - can anyone pleaseee point me in the right direction?

Best wishes Lee

3 Answers 3

3

You can do this with exp:stash:parse

{exp:stash:parse}
  {exp:channel:entries entry_id="{stash:recently-viewed}"}{title}{/exp:channel:entries}
{/exp:stash:parse}

You may need to add process="end" to the exp:stash:parse tag depending on the order of your templates.

2

Did you try adding parse="inward" to your channel entries loop so things are parsed in the right order? Would also add a dynamic="no" parameter in there for good measure.

{exp:channel:entries parse="inward" entry_id="{exp:stash:get name='recently-viewed'}" dynamic="no"}{title}{/exp:channel:entries}
1

It looks like your entry id is getting parsed before stash. If you turn on output debugging you should see that your entry id is getting output as {exp:stash:get name='recently-viewed'} rather than as the stashed content.

If you look at the New in V2.2.0 section in the Docs the developer explains parsing much better than I could ever. https://github.com/croxton/Stash

Maybe try the stash:embed functionality

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.