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

     

Stash embed: passing output of plugin tag as stash variable

Support Request

not-quite
not-quite

I apologize if I’m asking for something impossible here, but I just want to make sure that it really is impossible.

If I do something like this:

{exp:stash:embed:partials:articles stash:week-ago="2016-07-13 20:00"

where the partial “articles.html” contains a channel entries tag like this:

<h1>A week ago{stash:week-ago}</h1>
  
{exp:channel:entries start_on="{stash:week-ago}" ... 
      
<div class="title">{title}</div>
  
{/exp:channel:entries} 

everything works fine.  The week-ago value is displayed and template debugging shows that the channel entries tag is indeed being run with “2016-07-13 20:00” as the start_on parameter value.

However, I want the “week ago” value to be not hard-coded, but dynamic, so I wrote a simple plugin that returns the date from a week ago.  But if I change the embed to:

{exp:stash:embed:partials:articles stash:week-ago="{exp:my_plugin:week_ago}"

then although the embedded template shows the correct value of “2016-07-13 20:00” inside the <h1> tag, the template debugger shows that the tag itself is getting a start_on value of something strange, like a bunch of random characters (like a hash code).

I wrote the plugin hoping to avoid using PHP in my main template.  Or is PHP in the input phase the only way to do this?  Thanks for any suggestions you may have.