So, apologies I know this has been covered extensively BUT I've been pulling my hair out all day and still don't get why I can't get this to work.
I simply want to use a stash variable set in one channel entries call as a parameter value for categories in a channel entries call later on in the template.
I've set this in stash:
{!-- set some parameters --}
{exp:channel:entries channel='super_hub' limit='1'}
...
{!-- set the cfp id --}
{exp:stash:set name='cfpid'}
{shub_cfp_category:category_id}
{/exp:stash:set}
Then I'm trying to parse the value in a later channel entries call:
{!-- pull in recent CFPs --}
{exp:channel:entries channel='call_for_papers' limit='3' sort="desc" dynamic='no' category="{exp:stash:get name='cfpid'}" parse="inward"}
But this either doesn't call the right category entries, or doesn't run at all. I've tried different ways of setting the value and calling the value, and attempted using {exp:stash:parse} as well - all with no luck.
It feels like this is a scope issue, but what puzzles me is that I can display the stash value within the content of the second channel entries, but not use it as a parameter value in the call itself.
This seems like such a simple thing and I'm sure I'm doing something daft here. Please can someone help?
EDIT: thought I fixed it with Mark's help, but I've broken it again. Any inclusion of stash:parse just breaks the whole page. Below is the whole code:
{!-- retrieve layout --}
{embed='layouts/.default'}
{!-- set some parameters --}
{exp:channel:entries channel='super_hub' limit='1' parse_depth='2'}
{!-- set the title --}
{exp:stash:set name='title'}
{shub_display_title} |
{/exp:stash:set}
{exp:stash:set name='cfpid'}{shub_cfp_category:category_id}{/exp:stash:set}
{!-- set content --}
{exp:stash:set name="content"}
<article>
<div class="wrapper">
<header>
{!-- Add in display title and associated subtitles --}
<h1>{shub_display_title}</h1>
{!-- add in sharing buttons --}
{cpb_ptl_shr}
</header>
<div class="content">
<section class="shub">
{shub_playa_campaigns}
<div class="shubitem{switch=' ie-switch-alpha| ie-switch-beta'}">
{exp:switchee variable='{channel_short_name}' parse='inward'}
{!-- campaign page --}
{case value='campaign_page'}
<div class="item__img">
{if '{campaign_hero_image}' != ''}
{exp:ce_img:single src="{campaign_hero_image}" crop="yes|left,top|0,0"}
{if:else}
{exp:ce_img:single src="/assets/img/bdg/TFO-placeholder-hero.png" crop="yes|left,top|0,0"}
{/if}
</div>
<h3 class="item__header"><a href="{page_url}">CAM {campaign_display_title}</a></h3>
<a href="{page_url}"><div class="item__description">
{exp:ce_str:ing allow_eecode remove_html truncate="200"}{campaign_introductory_copy}{/exp:ce_str:ing}
</div></a>
{/case}
{!-- hub page --}
{case value='hub_page'}
<div class="item__img">
{if '{hub_hero_image}' != ''}{hub_hero_image}<img src="{url}">{/hub_hero_image}{/if}
</div>
<h3 class="item__header"><a href="{page_url}">HUB {hub_display_title}</a></h3>
<a href="{page_url}"><div class="item__description">
{exp:ce_str:ing allow_eecode remove_html truncate="200"}{hub_introductory_copy}{/exp:ce_str:ing}
</div></a>
{/case}
{!-- listing page --}
{case value='listing_page'}
<div class="item__img">
{if '{listing_hero_image}' != ''}{listing_hero_image}<img src="{url}">{/listing_hero_image}{/if}
</div>
<h3 class="item__header"><a href="{page_url}">LIS {listing_display_title}</a></h3>
<a href="{page_url}"><div class="item__description">
{exp:ce_str:ing allow_eecode remove_html truncate="200"}{listing_introductory_copy}{/exp:ce_str:ing}
</div></a>
{/case}
{/exp:switchee}
</div>
{/shub_playa_campaigns}
</section>
</div> {!-- /.content --}
{!-- close channel entries --}
{/exp:channel:entries}
{!-- secondary content --}
<div class="secondary">
<!-- CFP feed -->
<aside>
<h2>Call for papers</h2>
<div class="cfp-feed">
{!-- pull in recent CFPs --}
{exp:channel:entries channel='call_for_papers' limit='3' sort="desc" dynamic='no' category="{exp:stash:get name='cfpid'}" parse="inward"}
<div class="cfp-feed__item{switch=' ie-switch-alpha| ie-switch-beta'}">
<div class="cfp-feed__item__img">
{exp:playa:children field="cfp_journal"}
<a href="#{entry_id}">
{!-- <img class="cover" src="/uploads/images/journals/covers/{journal_acronym}.jpg" alt="{title}"/> --}
<img src="http://placehold.it/90x120">
</a>
{/exp:playa:children}
</div>
<div class="cfp-feed__item__description">
<a href="#{entry_id}">{cfp_display_title}</a><br>
<em>{cfp_journal}{title}{if journal_subtitle}: {journal_subtitle}{/if}{/cfp_journal}</em><br>
{if cfp_deadline}<time datetime="{cfp_deadline format="{DATE_W3C}"}">Deadline: {cfp_deadline format="%j %F %Y"}</time><br>{/if}
</div>
</div>
{/exp:channel:entries}
</div>
</aside>
<aside class="subject-profile">
<h2>Social Media for this subject</h2>
<ul class="iconic">
<li><i class="fa fa-facebook fa-2x"></i> <a href="#">Facebook</a></li>
<li><i class="fa fa-twitter fa-2x"></i> <a href="#">Twitter</a></li>
</ul>
</aside>
<aside class="promotion">
<h2>Sign up to stuff</h2>
<ul class="iconic">
<li><i class="fa fa-envelope"></i> <a href="#">Link to a bulletin or something</a></li>
<li><i class="fa fa-rss"></i> <a href="#">Perhaps an RSS feed?</a></li>
</ul>
</aside>
</div> <!-- /.secondary -->
</div> {!-- /.wrapper --}
</article>
<footer>
<div class="wrapper">
<!-- {cpb_ptl_pub_date} -->
</div>
</footer>
{/exp:stash:set}