I'm using Stash for the first time and having a little trouble getting a list of channel entries relating to a Zoo Visitor Member.
The main issue seems to be with the set_list
. If I hard-code the author_id
, it works fine, but if I try and pass it the member_id, it fails. I'm sure it's something simple and parse order related, but I'm just not seeing it.
I have checked out a couple of other answers: here and here. They have got me this far, but I'm still missing the final piece of the jigsaw!
Also, if there is any improvements to the way I've laid things out, I'd be very receptive to any tips, like I said it's my first time using Stash and I'd like to be doing it properly and as DRY as possible. Should I move the markup which is in the stash:content into a partial for example?
Here is the code I'm using:
{stash:embed:layouts:site}
{exp:channel:entries status="not closed"}
{exp:zoo_visitor:details member_entry_id="{entry_id}"}
{exp:stash:set name="team_member_id"}{visitor:member_id}{/exp:stash:set}
{/exp:zoo_visitor:details}
{exp:stash:set name="title"}{title}{/exp:stash:set}
{exp:stash:set name="h1"}{title}{/exp:stash:set}
{exp:stash:set name="team_member_photo"}{member_staff_photo}<img src="{url}" alt="{title}" title="{title}" />{/member_staff_photo}{/exp:stash:set}
{categories limit="1"}
{exp:stash:set name="team_member_category"}{category_name}{/exp:stash:set}
{/categories}
{exp:stash:set name="team_member_biog"}{member_biography}{/exp:stash:set}
{exp:stash:set name="team_member_firstname"}{member_firstname}{/exp:stash:set}
{/exp:channel:entries}
{exp:stash:set_list name="jobs" parse_tags="yes"}
{exp:channel:entries channel="job" status="not closed" dynamic="no" author_id="{exp:stash:get name="team_member_id"}"}
{stash:job_title}{title}{/stash:job_title}
{/exp:channel:entries}
{/exp:stash:set_list}
{exp:stash:set name="content"}
<div class="main">
<div class="banner">
<div class="content">
<h2 class="bb">Banner Title</h2>
<div>
<p>Banner Copy</p>
</div>
</div>
</div>
<div class="g2">
<div class="item single team">
<p>{exp:stash:get name="team_member_category"}</p>
</div>
<div class="item single">
{exp:stash:get name="team_member_photo"}
</div>
<div class="jobs double team">
<h3>{exp:stash:get name="team_member_firstname"}'s Jobs</h3>
<ul>
{exp:stash:get_list name="jobs"}
<li>{job_title}</li>
{/exp:stash:get_list}
</ul>
</div>
<div class="biog quad">
{exp:stash:get name="team_member_biog"}
</div>
</div>
</div>
{/exp:stash:set}
EDIT: Updated code adding gets and sets to stash tags to make more readable.
EDIT 2: Thanks to Jérôme for the solution, it's a combination of his suggestions. Here is the new working code for reference (the content section was unchanged, so is not included here):
{exp:stash:set parse_tags="yes" parse_depth="2"}
{exp:channel:entries status="not closed"}
{exp:zoo_visitor:details member_entry_id="{entry_id}"}
{stash:team_member_id}{visitor:member_id}{/stash:team_member_id}
{/exp:zoo_visitor:details}
{stash:title}{title}{/stash:title}
{stash:h1}{title}{/stash:h1}
{stash:team_member_photo}{member_staff_photo}<img src="{url}" alt="{title}" title="{title}" />{/member_staff_photo}{/stash:team_member_photo}
{categories limit="1"}
{stash:team_member_category}{category_name}{/stash:team_member_category}
{/categories}
{stash:team_member_biog}{member_biography}{/stash:team_member_biog}
{stash:team_member_firstname}{member_firstname}{/stash:team_member_firstname}
{/exp:channel:entries}
{/exp:stash:set}
{exp:stash:set_list name="jobs" parse_tags="yes"}
{exp:channel:entries parse="inward" channel="job" status="not closed" dynamic="no" author_id="{exp:stash:team_member_id}"}
{stash:job_title}{title}{/stash:job_title}
{/exp:channel:entries}
{/exp:stash:set_list}