1

I'm using EE 2.7.2 with Stash 2.4.7.

I'm attempting to stash an entry_id and then retrieve it again elsewhere on the page.

I've got a site with two important channels - people and awards. On each award, I've got a relationship field (award_winner) that points to someone in the people channel.

On any given award detail page, I'm trying to pull in a bunch of information related to the award winner and stick it in a sidebar.

At the top of a page, I stash an entry ID for a related entry.

{exp:stash:parse}
  {exp:channel:entries channel="awards"}
    {award_winner}
      {exp:stash:set_value name="winner_id" value="{award_winner:entry_id}"}
    {/award_winner}
  {/exp:channel:entries}
{/exp:stash:parse}

This is working correctly. If I do a *{exp:stash:get name="winner_id"}* on its own, I get the proper entry ID, but it's not showing up when I try to stick it into exp:channel:entries.

Down in the sidebar, I'm pulling in a list of entries related to that award winner.

And I'm trying to do that like so:

{exp:channel:entries channel="people" entry_id="{exp:stash:get name="winner_id" parse="inward"}" dynamic="no"}
  <h2>Other awards won by {title}</h2>
    <ul>
      {parents field="award_winner"}
        <li>{parents:title}</li>
      {/parents}
    </ul>
{/exp:channel:entries}

When it gets to this second part, it's returning all entries in the people channel, instead of just the one defined by *winner_id*.

The end goal, will be to have a bunch of channels (news, media, etc) that all relate to individuals, and that sidebar area is going to pull in (on any given page) a bunch of related items from multiple channels.

1 Answer 1

1

Just a couple of points of guidance if you want to use that technique with parse="inward":

  1. parse="inward" needs to be on the outer tag so that it instructs the inner tags in parameters to be parsed
  2. be careful to use double quote marks and single quote marks as appropriate when nesting

Here's how to make your code work without the need for parse="inward". (See the previous revision of this answer to see how it would work with parse="inward".)

{!-- ====================================
SET
========================================= --}

{exp:channel:entries channel="awards"}
  {award_winner}
    {exp:stash:set_value name="winner_id" value="{award_winner:entry_id}"}
  {/award_winner}
{/exp:channel:entries}

{!-- ====================================
GET
========================================= --}

{exp:stash:parse process="end"}
  {exp:channel:entries
    channel="people"
    entry_id="{stash:winner_id}"
    dynamic="no"
  }
    <h2>Other awards won by {title}</h2>
    <ul>
      {parents field="award_winner"}
        <li>{parents:title}</li>
      {/parents}
    </ul>
  {/exp:channel:entries}
{/exp:stash:parse}
1
  • Thanks. This worked well. Looks like I was over-complicating my code.
    – SamC
    Dec 16, 2013 at 16:11

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.