Extension, Module

Archived
Forum
(read-only)

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

     

exp:stash:parse process=“end” outputting placeholder

Support Request

REMOVED20220630
REMOVED20220630

Hello!  I am attempting to use Stash to pass a category list to a calendar loop (the Events Calendar module from Solspace):

This is the template:

<!-- BEGINtemplates/blocks/events-regional -->
<
hr />
<
div class="wysiwyg" style="padding-right: 10px; margin-right:5px;">
<
ul class="pagination margin_bottom_04 pagerControl" data-pagination="{'items_per_page':3}"></ul>
Categories[{exp:stash:get name='current_category_list'}] <!-- this is just for testing purposes -->
<
h3 class="margin_bottom_03">Upcoming Events</h3>
    
{exp:stash:parse process="end"}
        {exp
:calendar:events
            dynamic
="no"
            
event_limit="3"
            
event_offset="{global:pagination_offset}"
            
category="{exp:stash:get name='current_category_list'}"
            
status="open"
            
{global:transcribe}}
            {if no_results}
                
<p>We're busy planning. Please check back.</p>
            {/if}
            <div class="listitem">
                {snippet:events_row_detailed}
            </div>
        {/exp:calendar:events}
    {/exp:stash:parse} 
</div>
<!--   END: templates/blocks/events-regional --> 

This template is embedded (via Matrix) as a block using Litzinger’s Snippet and Template Select FT, and the overall thing uses the Stash master layout model and is within a channel entries loop ultimately and the stash variabled for current_category_list is populated in the layout template like this:

{exp:stash:set_value name="current_category_list" value="{categories backspace='1'}{category_id}|{/categories}"

Nevertheless, without the stash:parse and by hard coding category IDs, this works as expected.  Without the stash:parse, category is blank due to parse order.  When the parse tag is wrapped around the calendar tag, I get:

{6ee64145dfa4ae5926a9c326266d59548796} 

When rendered, it looks like this:
http://screencast.com/t/RcgKk5lOnHFl

 

 

REMOVED20220630
# 1
REMOVED20220630

one other note—putting parse around the actual channel entries loop breaks a large number of things across the site, so that’s not really possible either…

Mark Croxton
# 2
Developer
Mark Croxton

When you pass a tag as a parameter you need to use parse=“inward” on the parent tag. Alternatively when parsing a block of tags with stash you can also access Stash variables as placeholders in the form {stash:my_variable}.

The other oddity you may be encountering is the way EE caches identical tags that are used multiple times in the same template. Append the word ‘random’ to second instances of the same tag to prevent this with your current_category_list variable.

Finally, please make sure you have enabled the Stash extension.

REMOVED20220630
# 3
REMOVED20220630

hmm.  none of that worked…  parse order problems are such a pain.

Litzinger’s template and snippet select fieldtype chokes when I put any tags in as parameter values (but it does drop in typical template embed variable parameters when they are just strings).  I’m actually looking at modding that fieldtype to hook into Stash so I can pass in a stash_var=“stash_var_name” parameter and then have the plug in extract the value, and create an embed variable out of it since when I hardcode the embed variable with a list of category IDs where the template is embedded, this all works like a charm—except the whole hardcoded value thing…

In mod.stash, in the get method, it says:

static call within PHP enabled templates or other add-on: <?php echo stash::get(‘title’) ?>

I’ve tried that syntax, but I get a Class doesn’t exist error.  This seemed to work

require_once PATH_THIRD 'stash/mod.stash.php';
$stash = new Stash();
echo 
$params['stash_var']//--> returns "current_category_list"
echo $stash::get("current_category_list"); //--> returns "" 

In the original block above, I added:

<p>Embed:[{embed:current_category_list}]</p>
<
p>Stash:[{exp:stash:get name="current_category_list"}]</p

This renders:
Embed:[]
Stash:[16|18]

So, I know the data is in Stash somewhere.  and I know the stash var name is getting into the plugin, but I can’t seem to get the value.  I’m sure I’m just missing something…  any ideas?

 

Mark Croxton
# 4
Developer
Mark Croxton

If you search for your variable in the template debug output you will find lines logged by Stash, which will tell you when the variable was set and the value captured, and when it was retrieved. Please let me know what they say.