Stash
ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6
Back to this add-on's main page
View Other Add-ons From Mark Croxton
Stash Category ID with Prev/Next Entry Linking
Support Request
Design Station
|
Posted: 31 March 2017 08:40 PM |
|
|
|
Hi there,
I’m trying to use Stash to grab a single entry’s category ID and pass that along to the Prev/Next entry linking so that those direct only to entries in the same category ID. I want to do it dynamically so that I don’t end up with a dozen different templates just to solve the entry linking issue.
I successfully have Stash grabbing the Category ID, but even if I try setting the Prev/Next entry linking to parse last, looking at the debugging info shows that Stash is still setting the Category ID value after the Prev/Next tags have been done.
I’ve got Stash running in a Template Partial as I read that those are prioritized, but it doesn’t seem to run any sooner. Here’s the code I’m using for that:
{exp:stash:set name="road-id"}{categories}{category_id}{/categories}{/exp:stash:set}
And what’s actually on the page:
{page-head} <title>{exp:channel:entries channel="sites" limit="1"}{title}</title> </head> <body id="south">
{page-nav}{page-stash}
<div class="region"> <div class="row"><div class="twelve columns"><h2>{categories}{category_name}{/categories}{if site-kilometre}, Km. {site-kilometre}{/if}</h2><h1>{title}</h1></div></div> </div>
<div class="row"> <div class="eight columns"> <div class="panel"> {if site-image}<img src="{site-image}" alt="{title}" />{/if} {site-content}{/exp:channel:entries} {exp:stash:parse process="end"}{exp:channel:next_entry category="{exp:stash:get name='road-id'}"}<p class="body-nav">→ <span class="bold"> Next </span><a href="{path=south/site/}">{title}</a></p>{/exp:channel:next_entry} {exp:channel:prev_entry category="{exp:stash:get name='road-id'}"}<p class="body-nav">← <span class="bold"> Previous </span><a href="{path=south/site/}">{title}</a></p>{/exp:channel:prev_entry}{/exp:stash:parse} </div> </div> <div class="four columns"> <ul class="accordion">{exp:channel:category_archive channel="sites" style="linear" show_empty="no" orderby="date" show="13|14|15|16"} {categories}<li><div class="title"><h5>{category_name}</h5></div> <div class="content"> <ul class="side-nav"> {entry_titles}<li><a href="{path='south/site/'}">{title}</a></li>{/entry_titles} </ul> </div> </li>{/categories} {/exp:channel:category_archive}</ul> </div> </div> {page-footer}
This code just ends up producing the 6ee64145dfa4ae5926a9c326266d5954230554385 placeholder text.
Has anyone tried something similar? I’ve looked around but nothing seems to match up.
Thanks!
|
|
|
Mark Croxton
|
Posted: 20 April 2017 06:49 AM |
# 1
|
|
Developer
|
Set as a ‘global’ variable so you can access it directly like {st_road-id} inside stash-parsed blocks:
{categories limit="1"}{exp:stash:set name="st_road-id" type="global"}{category_id}{/exp:stash:set}{/categories}
And then:
{exp:stash:parse process="end"}{exp:channel:next_entry category="{st_road-id}"}<p class="body-nav">→ <span class="bold"> Next </span><a href="{path=south/site/}">{title}</a></p>{/exp:channel:next_entry} {exp:channel:prev_entry category="{st_road-id}"}<p class="body-nav">← <span class="bold"> Previous </span><a href="{path=south/site/}">{title}</a></p>{/exp:channel:prev_entry}{/exp:stash:parse}
|
|
|
Design Station
|
Posted: 20 April 2017 02:57 PM |
# 2
|
|
|
Hi Mark,
Thanks for the reply! Unfortunately something is still not quite right and the entry linking placeholder is not being replaced during Stash’s post-processing. Here’s the full debugging output…
0.000017 / 6.3MB - Begin Template Processing - 0.000044 / 6.3MB URI: south/beta/robinson-roadhouse 0.000049 / 6.3MB Template: / 0.002373 / 6.5MB Template Group Found: south 0.002783 / 6.5MB Retrieving Template from Database: south/beta 0.008214 / 7.9MB Calling Extension Class/Method: Stash_ext/template_fetch_template 0.008332 / 7.9MB Template Type: webpage 0.008345 / 7.9MB Parsing Site Variables 0.008720 / 7.9MB Config Assignments & Template Partials 0.009073 / 7.9MB Parse Current Time Variables 0.009538 / 7.9MB Parsing Segment, Embed, Layout, logged_in_*, and Global Vars Conditionals 0.017896 / 8.4MB - Beginning Tag Processing - 0.017911 / 8.4MB Detecting Tags in Template 0.018109 / 8.4MB Running Tags 0.024542 / 8.1MB Calling Tag: {exp:channel:entries channel="sites" limit="1" disable="member_data"} 0.093445 / 14.0MB -> Data Returned 0.168224 / 14.8MB Calling Tag: {exp:stash:parse process="end"} 0.173750 / 15.0MB Stash: this tag will be post-processed on end: {ee()->TMPL->tagproper} 0.173791 / 15.0MB -> Data Returned 0.174126 / 15.0MB Calling Tag: {exp:channel:categories channel="sites" style="linear" show="13|14|15|16"} 0.179652 / 15.2MB -> Data Returned 0.179719 / 15.1MB Detecting Tags in Template 0.179817 / 15.2MB No Closing Tag 0.180115 / 15.2MB Running Tags 0.180294 / 15.2MB Calling Tag: {exp:stash:set name="st_road-id" type="global"} 0.180660 / 15.2MB Stash: SET st_road-id to value: 0.180688 / 15.2MB -> Data Returned 0.182216 / 15.4MB Calling Tag: {exp:gmaps:init} 0.183587 / 15.2MB -> Data Returned 0.183990 / 15.2MB Calling Tag: {exp:gmaps:map width="100%" zoom="12" center:latlng="60.448949,-134.846895"} 0.195649 / 15.7MB -> Data Returned 0.195918 / 15.7MB Calling Tag: {exp:channel:entries category="13" dynamic="no" orderby="date" sort="asc" disable="member_data"} 0.289644 / 17.5MB -> Data Returned 0.289898 / 17.5MB Calling Tag: {exp:channel:entries category="14" dynamic="no" orderby="date" sort="asc" disable="member_data"} 0.325427 / 17.9MB -> Data Returned 0.325710 / 17.9MB Calling Tag: {exp:channel:entries category="15" dynamic="no" orderby="date" sort="asc" disable="member_data"} 0.353330 / 18.2MB -> Data Returned 0.353593 / 18.2MB Calling Tag: {exp:channel:entries category="16" dynamic="no" orderby="date" sort="asc" disable="member_data"} 0.373795 / 18.5MB -> Data Returned 0.373851 / 18.5MB - End Tag Processing - 0.374124 / 18.6MB Calling Extension Class/Method: Stash_ext/template_post_parse 0.374276 / 18.6MB Stash: post-processing tag: {exp:stash:parse process="end"} will be replaced into {6ee64145dfa4ae5926a9c326266d59542093151690} 0.374378 / 18.6MB Stash: processing inner tags 0.374641 / 18.6MB Calling Extension Class/Method: Stash_ext/stash_fetch_template 0.375085 / 18.6MB Calling Tag: {exp:channel:next_entry category="14"} 0.377337 / 18.5MB -> Data Returned 0.377542 / 18.5MB Calling Tag: {exp:channel:prev_entry category="14"} 0.378951 / 18.5MB -> Data Returned 0.379007 / 18.4MB Stash: processing inner tags 0.379232 / 18.4MB Calling Extension Class/Method: Stash_ext/stash_post_parse 0.379434 / 18.5MB Stash: batch processing queued queries 0.380135 / 18.5MB Calling Extension Class/Method: Gmaps_ext/template_post_parse 0.380781 / 18.4MB - End Template Processing - 0.380789 / 18.4MB Parse Global Variables 0.383278 / 18.5MB Template Parsing Finished
So Stash is definitely grabbing the entry’s category perfectly, and is actually passing that on to the previous/next fields exactly as it should. It’s just not replacing the placeholder (if I understand the process correctly). Is this still a parse order issue?
Thank you!
Christopher
|
|
|
Design Station
|
Posted: 05 May 2017 11:41 AM |
# 3
|
|
|
Just an update for anyone who is interested: it turned out this was a Post Processing conflict with the Gmaps add-on. I contacted that developer, and he’s resolved that issue based on the solution Mark provided in this thread: https://devot-ee.com/add-ons/support/stash/viewthread/16305
|
|
|