Git Product home page Git Product logo

stash's Introduction

DEPRECATED

If you're starting a new ExpressionEngine project today, please consider using Twig for templating via Coilpack.

Stash

Release

Stash for ExpressionEngine 3.0 to 7.0+.

Description

Stash allows you to stash text and snippets of code for reuse throughout your templates. Stash extends ExpressionEngine’s template parser with powerful features such as variables, lists, parse-order control, template partials, inheritance, layouts, caching and more. It will transform the way you think about and write templates.

Documentation

https://github.com/croxton/Stash/wiki/

Copyright (c) 2023 Hallmark Design https://hallmark-design.co.uk

stash's People

Contributors

croxton avatar elivz avatar epocsquadron avatar filipvds avatar gdmac avatar rsanchez avatar since1976 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stash's Issues

stash:get_list is only called one time

I identified an issue with get_list that only appeared in a specific syntax.

The following code works. It returns the correct number of related children:

{exp:channel:entries channel="{segment_2}" limit="10" orderby="entry_date" sort="desc" status="published" dynamic="no"}
    {exp:stash:set_list name="total_children" parse_tags="yes"}
        {stash:photogallery_total_children}{exp:playa:total_children channel="photogallery" status="published"}{/stash:photogallery_total_children}
        {stash:video_total_children}{exp:playa:total_children channel="video" status="published"}{/stash:video_total_children}
    {/exp:stash:set_list}

    {exp:stash:get_list name="total_children"}
        {if "{photogallery_total_children}" > 0}
            <span class="photo"><a href="{site_url}/library/{channel_name}/{url_title}">{photogallery_total_children} {if "{photogallery_total_children}" > 1}{photogalleries_{language_code}}{if:else}{photogallery_{language_code}}{/if}</a></span>
        {/if}
        {if "{video_total_children}" > 0}
            <span class="video"><a href="{site_url}/library/{channel_name}/{url_title}">{video_total_children} {if "{video_total_children}" > 1}{videos_{language_code}}{if:else}{video_{language_code}}{/if}</a></span>
        {/if}
    {/exp:stash:get_list}
{/exp:channel:entries}

But the code here under only return the total children for the first entry, and repeat that result for every other entries:

{exp:channel:entries channel="{segment_2}" limit="10" orderby="entry_date" sort="desc" status="published" dynamic="no"}
    {exp:stash:set_list name="total_children" parse_tags="yes"}
        {stash:photogallery_total_children}{exp:playa:total_children channel="photogallery" status="published"}{/stash:photogallery_total_children}
        {stash:video_total_children}{exp:playa:total_children channel="video" status="published"}{/stash:video_total_children}
    {/exp:stash:set_list}

    {exp:stash:get_list name="total_children"}
        {if "{photogallery_total_children}" > 0}<span class="photo"><a href="{site_url}/library/{channel_name}/{url_title}">{photogallery_total_children} {if "{photogallery_total_children}" > 1}{photogalleries_{language_code}}{if:else}{photogallery_{language_code}}{/if}</a></span>{/if}
        {if "{video_total_children}" > 0}<span class="video"><a href="{site_url}/library/{channel_name}/{url_title}">{video_total_children} {if "{video_total_children}" > 1}{videos_{language_code}}{if:else}{video_{language_code}}{/if}</a></span>{/if}
    {/exp:stash:get_list}
{/exp:channel:entries}

Cheers!

Deprecated function decode_date()

Hi Mark,

I am using the most recent dev release of Stash. I updated to EE 2.6.1 and noticed the following message in the Developer Logs:

Deprecated function decode_date() called in system/expressionengine/third_party/stash/mod.stash.php on line 2609. Deprecated since 2.6. Use Localize::format_date instead.

Definitely not a "show-stopper", but I thought I would bring it to your attention. Thanks!

Phantom tags when using Stash embeds

I've been looking at reworking the way I use Stash to start using embeds and have run into a problem with getting an error for {exp:taxonomy:nav} being in my template when it's not installed.

I started off by copying the examples at the bottom of https://github.com/croxton/Stash/wiki/Embeds and the layouts template there includes the taxonomy tag, but I've since taken it out, but still getting the error.

My templates look like this:

EE template at site/page

{stash:embed
    name="views:page"
    parse_stage="both"
}

Stash template at views/page

{stash:embed
    name="layouts:global"
}

{exp:channel:entries
    channel="site"
    url_title="{last_segment}"
    disable="categories|member_data|pagination|trackbacks"
}
    {exp:stash:set_value name="st_page_title" value="{title}"}

    {exp:stash:set name="st_content"}
        <h1>{title}</h1>
        {body}
    {/exp:stash:set}

{/exp:channel:entries}

Stash template at layouts/global

<!doctype html>
<!--[if lt IE 9]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
    <meta charset="utf-8">
</head>
<body class="{stash:_body_class}">
    <div id="wrap">
        <header role="banner">
        </header>
        <div id="content">
            <article role="main">
                {exp:stash:get name="st_content"}
            </article>
        </div>
    </div>
    <footer role="contentinfo">
        <p>&copy; </p>
    </footer>
</body>
</html>

It's like the page has been cached but I haven't set up Stash cacheing yet and there's no other cacheing modules involved.

optional paramater to save a stash:embed as a var

I find myself often using stash:embeds for code reuse.

I find myself doing this alot:

{exp:channel:entries
  disable="categories|category_fields|member_data|pagination|trackbacks"
  dynamic="yes"
  require_entry="yes"
}
    {exp:stash:content}
      {stash:embed:tab_products
        process="start"
        stash:field="cf_store_product_suggested"}
    {/exp:stash:content}
{/exp:channel:entries}
...
 {exp:stash:get name="content"}

What do you think about adding a param to to stash:embed save the output to a stash var? Or maybe use the output param? So it might look like:

      {stash:embed:tab_products
        process="start"
        output="variable|snippet"
        name="content
        stash:field="cf_store_product_suggested"}
...
 {exp:stash:get name="content"}

Does that make sense?

Return parameter for unset?

Can I suggest a return parameter in stash:unset. It's useful (imo) to be able link to a template with just something like {exp:stash:unset name="recently-viewed"} in it. The return parameter would let me unset a stash name manually and then instantaneously return to the page I clicked an unset link on, or else where.

Best wishes
Lee

Static Stash / Parse Order

We are trying to use static caching but certain tags aren't parsing before the static file gets stored. Examples would include the {site_name} and the ACT ID from Low Search. The top of our templates looks like...

{stash:embed file_name="layouts:basic" parse_stage="set"}
{exp:stash:static name="homepage"}

Below that we have a few stashes that get pulled into the layout stash. Any thoughts? Thanks!

If the last variable in a exp:stash:set_list is empty it outputs the {tag}

I am having an issue where if the last variable in a exp:stash:set_list is empty it is outputting the {tag} on the front-end. The issue seems to be that there is no closing pipe, I have pasted an example below from the template debugger.

event_entry_id|=|695|&|event_title|=|GALA|&|event_url_title|=|gala|&|event_start_date|=

I found that adding an empty variable {stash:dummy}{/stash:dummy} to the end of the list fixes it for the time being.

event_entry_id|=|695|&|event_title|=|GALA|&|event_url_title|=|gala|&|event_start_date|=||&|dummy|=

Not sure if this is a bug or I am missing something.

Thanks.

Bundle with stash:embed

Would it be possible to set a bundle on a stash:embed? This would save us from using a separate cache tag when setting process="cache" on the embed. Thanks for all the hard work, the new static caching and mustache are excellent.

Flush Cache

Could you add a settings panel to the control panel to clear the template cache? I want to switch my sites into production mode with embed templates, but then I'm not sure how to best refresh things when I make updates.

Do you just switch stash_file_sync back to true?

We use stash on an MSM install where several sites all load the same files as embed. Would I have to switch all the sites to sync and load the page that uses the template and then switch them all back? (That's part of why I want a control panel screen where I could clear it all in one swipe.)

Odd string when trying to use {stash:embed} - PHP 5.4.x compatiblity

I'm getting a very odd error when I try to use {stash:embed}

Here's what the template debugger says:
{exp:stash:embed name="callouts"} will be replaced into {09e4fcedba20c3846553bac3d8265171388272865}

And then "{09e4fcedba20c3846553bac3d8265171388272865}" is where the embed should be.

Undefined index: Stash_ext

Tried 2.2.7 and get these errors on a page using: {exp:stash:set name="boutique" parse_tags="yes" save="yes"}{exp:surgeree:all_segments}{/exp:stash:set}

A PHP Error was encountered
Severity: Notice

Message: Undefined index: Stash_ext

Filename: libraries/Extensions.php

Line Number: 236

A PHP Error was encountered
Severity: Notice

Message: Undefined index: Stash_ext

Filename: libraries/Extensions.php

Line Number: 238

A PHP Error was encountered
Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /data/sites/web/site/www/system/codeigniter/system/core/Exceptions.php:170)

Filename: core/Common.php

Line Number: 408

Stash variables consistent case use

When setting or getting a Stash variable, capital letters in the name parameter are converted to lowercase. But when Stash is parsing a block of tags placeholders for variables are not converted to lowercase before being replaced.

Stash should do one of the following:

  1. make it clear in the docs that only lowercase letters should be used for variable names
  2. convert placeholders to lowercase automatically
  3. permit mixed-case variable names.

Possible issues:

2 - requires extra processing when parsing
3 - given that Stash variables may correspond to template files this later solution would mean Stash assumes a case-sensitive file system is being used, which may not be the case.

Conditional and segment

Hi Mark,

sorry to annoy you again, but I'm stuck:

{exp:stash:set name="default_channel" parse_tags="yes" parse_conditionals="yes"}{if segment_3}{segment_3}{if:else}document{/if}{/exp:stash:set}

{exp:channel:entries channel="{exp:stash:get name="default_channel" default="docucment" parse="inward"}" }

This piece of code is not working when segment_3 is empty. If I add save="yes" to stash:get, just to see what's happened, I see in the db that the value is document, but it is empty in the channel="" parameter. But as soon as I have segment_3, it's ok, channel="" get it.
A bit lost on that one.

Cheers!

Pv

Stash not parsing all tags?

I have this code: http://pastie.org/private/6undc80rwmfwkmd1ynl1g
(note I've tried all kinds of parse_depth's, this one is extreme, obviously)

Which is resulting in this in the db: http://pastie.org/private/g3u6d6ri6sdn5on2bw8lda
(note some parsed tags, many not parsed)

I am grabbing the above stored stash out of the db via an extension and inserting it into the body of a freeform email. I need all tags to be parsed (meaning I need stash to parse everything and store just the resulting HTML in the db). Here is what I see when I test output what should be going into the email body: http://cl.ly/image/1c1z0h2m0Z0j

I can't figre out why all the tags won't parse before the stash is stored. Can you tell me where I am doing it wrong?

not_empty conditional and process="end"

If you need to use process="end" on a not_empty conditional, it won't work.

I understand why this has to be the case, with the way process="end" works using template_post_parse, but maybe we can use this thread to brainstorm workarounds?

This is an example of what doesn't work.

{if {exp:stash:not_empty name="foo" process="end"}}
<div id="foo">{exp:stash:get name="foo"}</div>
{if:else}
<p class="alert">There is no "foo"</p>
{/if}

What if you allowed get as a tag pair?

{exp:stash:get name="foo" process="end"}
{if no_results}
<p class="alert">There is no "foo"</p>
{/if}
<div id="foo">{variable}</div>
{/exp:stash:get}

You'd have to have some variable in the tag pair that actually prints variable. {get}? {stash}? {variable}?

Parsing error with Playa in Matrix

Hi Mark,

I know, it's a bit spaghetti code but:

{exp:stash:set name="parser" parse_tags="yes" parse_depth="2"}
{exp:channel:entries channel="programme" disable="member_data|pagination|categories" dynamic="no"}
        {exp:stash:append_list name="programme_tabs" save="yes" scope="site"}
            {stash:item_title}{title}{/stash:item_title}
            {stash:headline}{programme_headline}{/stash:headline}
            {stash:tabs}
                {programme_sessions}
                    <h3>{session_start} &rarr; {session_end}: {session_title}</h3>
                    <div>
                        {session_speaker}
                            <p>Speaker: <a href='/speakers/index#{entry_id}'>{title}</a> (<a href='{speaker_cv}' title='cv'>CV</a>)</p>
                            <p>Pic: <img src='{speaker_picture}' width='100' /></p>
                        {/session_speaker}
                        {session_summary}
                    </div>
                {/programme_sessions}
            {/stash:tabs}
        {/exp:stash:append_list}
{/exp:channel:entries}
{/exp:stash:set}

As you can see, I had to use single quotes in the {session_speaker} Playa tag pair, because double quotes was crashing the page. The error was:

 Parse error: syntax error, unexpected '>' in /system/expressionengine/libraries/Functions.php(659) : eval()'d code on line 163

In fact, as soon as I add any double quote in between the Playa, the page crash.

I tested with both 2.1.0 and beta.

Cheers,

Pv

<button></button> seems to break a stash

If I add a <button> element in my stash it breaks the stash at that point. I replaced it with an <a> so it's not a show stopper, just wanted you to know. I'm using twitter bootstrap modal to hide some content below.

My code:

{exp:stash:set name="highlightRelationship{segment_1}{segment_2}" save="yes" scope="site" replace="no" parse_tags="yes" parse_depth="2"}
            {exp:playa:children field="{segment_1}_highlight_relationshi"}
            <aside class="span3 relatedHighlight">
                <a data-toggle="modal" href="#myModal{entry_id}">
                    {exp:ce_img:single src="{highlight_image}" width="270" crop="yes" class="highlightImage" alt="{title} Image"}
                    <div class="asideContent">
                    <h4>{title}</h4>
                    {exp:eehive_hacksaw words="32" append="..." allow="<p><strong><em><i><b>"}
                        {highlight_body}
                    {/exp:eehive_hacksaw}
                    </div>
                </a>
            </aside>
            <div class="modal hide" id="myModal{entry_id}">
                <div class="modal-header">
            <button data-toggle="modal" href="#myModal{entry_id}">X</button>
                    <h3>{title}</h3>
                </div>
                <div class="modal-body">
                    {exp:ce_img:single src="{highlight_image}" width="270" crop="yes" class="highlightImage" alt="{title} Image"}
                    <small>{if highlight_link}<a href="{highlight_link}" rel="nofollow" target="_blank">{highlight_client_name}</a>{/if}{if highlight_link == ""}{highlight_client_name}{/if}</small>
                    {highlight_body}
                </div>
                <div class="modal-footer">
                    <a href="#" class="btn" data-dismiss="modal">Close</a>
                </div>
            </div>
            {/exp:playa:children}
        {/exp:stash:set}

Stash Set/Append and Whitespace

I am trying to build out a query for the query module and despite having a trailing/leading whitespacing when setting or appending it gets stripped. I thought trim was set to no by default but even specifically setting it doesn't seem to help. Any thoughts? Thanks.

Creating a list in a exp:stash:set tag pair

Hello Mark,

Using the exp:stash:set tag pair without a name, I define the following:

{exp:stash:set parse_tags="yes"}
    {stash:main_content}

        {exp:channel:entries ...}           

            ...

        {/exp:channel:entries}

    {/stash:main_content}
{/exp:stash:set}

I was wondering if it is possible, between the exp:channel:entries tag pair, to use exp:stash:append_list somehow?
At the moment, if I use this tag, the list is unfortunately not created.

Thanks a lot for your time (and for creating such a great add-on),

Quentin

Add a "trim" attribute

It would be helpful to have the ability to trim the contents of a set or get action. For example:

{exp:stash:set name="foozle" parse_tags="yes"}
    {if foo == 'bar'}

    {/if}
{/exp:stash:set}

...

{if {exp:stash:not_empty name="foozle"}}
    // Will eval to true no matter what as a string of whitespace is "true" in PHP
{if:else}
    // ...
{/if}

Although you could get around this issue by using the filter attribute, it seems more intuitive to give some control over the trimming:

{exp:stash:set name="foozle" parse_tags="yes"}
    {if foo == 'bar'}

    {/if}
{/exp:stash:set}

...

{if {exp:stash:not_empty name="foozle" trim="yes"}}
    {exp:stash:get name="foozle"}
{if:else}
    Foozle is empty!
{/if}

You could even get crazy and allow passing a trim character, just like PHP's trim function allows.

DB Error on Import

Trying to import an EE database and ran into this little gem. 2.3.6 Stash and 2.5.5 EE installs.


LATEST FOREIGN KEY ERROR

130417 9:44:37 Error in foreign key constraint of table testing/exp_stash:
FOREIGN KEY (bundle_id) REFERENCES exp_stash_bundles (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8:
Cannot resolve table name close to:
(id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8

:::::From the DB Table entry being imported::::
DROP TABLE IF EXISTS exp_stash ;
CREATE TABLE exp_stash (id int(11) unsigned NOT NULL auto_increment, site_id int(4) unsigned NOT NULL default '1', session_id varchar(40) default NULL, bundle_id int(11) unsigned NOT NULL default '1', key_name varchar(64) NOT NULL, key_label varchar(64) default NULL, created int(10) unsigned NOT NULL, expire int(10) unsigned NOT NULL default '0', parameters text, PRIMARY KEY (id), KEY bundle_id (bundle_id), KEY key_session (key_name,session_id), KEY key_name (key_name), KEY site_id (site_id), CONSTRAINT exp_stash_fk ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Stash embed rendering inside no_reverse_related_entries

I posted an issue at the EESE site but I am not sure if this is a bug or not. The original question can be found here if this is not a bug.

If I comment out the regular embed below, and uncomment the stash embed, the stash embed is rendering inside the "if no_reverse_related_entries" tag pair regardless of whether there are related entries or not.

{if no_reverse_related_entries}
  {embed="test/random_header_image"}
  {!-- {stash:embed:includes:em_random_header_image} --}
{/if}

Conditional if stash is set and errors with whitespace, returns, and tabs

We find ourselves using Stash to help us set some complex conditionals in EE. Example:

{if '{exp:stash:get name='"test"}'}
    Do this
{/if}

However, this means we can't have any whitespace in the {exp:stash:set} or else {exp:stash:get} thinks it is being set.

For example, writing it out like this:

{exp:stash:set name="test" parse_tags="yes"}
    {exp:channel:entries
        channel="page"
        limit="1"
        dynamic="no"
        disable="categories|category_fields|member_data|pagination"}

        {custom_field}

    {/exp:channel:entries}
{/exp:stash:set}

Stash thinks it is being set because there is whitespace, tabs, returns, etc. If I write it like this:

{exp:stash:set name="test" parse_tags="yes"}{exp:channel:entries channel="page" limit="1" dynamic="no" disable="categories|category_fields|member_data|pagination"}{custom_field}{/exp:channel:entries}{/exp:stash:set}

This works just fine because it determines if the custom field exists, not just the whitespace, tabs, etc.

Nesting blocks

I may be missing something, but it seems like there is no way to nest blocks. This would be handy when using the template override method to, for instance, be able to override either the entire content section or just the sidebar within it. Is that possible, either now or in the future? Or are there parsing issues that prevent it from working?

Example:

{exp:stash:block name="page_content"}
    <div class="content">
        <div class="body" role="main">
            {exp:stash:block name="page_body"}
                <h1 class="entry-title">{exp:stash:title}</h1>
                {exp:stash:body}
            {/exp:stash:block}
        </div>
        <div class="sidebar">
            {exp:structure:nav start_from="/{segment_1}"}
            {exp:stash:sidebar}
        </div>
    </div>
{/exp:stash:block}

parse_tags has no effect one way or the other

When I use the example below from the README, my template tags are parsed the same regardless of the parse_tags parameter.

{exp:stash:set
    name="my_cached_blog_entries" 
    save="yes" 
    scope="site" 
    parse_tags="yes"
    replace="no" 
    refresh="60"
    output="yes"
}
    {exp:channel:entries channel="blog"}
        <p>{title}</p>
    {/exp:channel:entries}
{/exp:stash:set}

Am I missing something here?

stashing channel:entries and no_results

I have a main_content stash filled with data and prepending team data.
it looks like the no_results is not stashed.

{embed="layouts/mainpage"}

{exp:stash:prepend name="main_content"}
  {exp:channel:entries channel="team" url_title="{segment_3}"}
    <div class="teammember">
      {title}
      {description}
    </div>
    {if no_results}teammember(s) not found{/if}
  {/exp:channel:entries}
{/exp:stash:prepend}

save/cache exp:stash:set WITHOUT name, with wrapped names

It seems that exp:stash:set WITHOUT name= (e.g. with wrapped stash pairs) doesn't honor save=yes and replace=no somehow. Is this intended behaviour? if so, is there a way to save the wrapped variables?

(edit: the following example fetches two entries from a channel, each one from a particular category. It first fetches one entry from category-one and then one entry from category-two. Because an entry can be assigned to multiple categories, it is possible that the second channel:entries tag fetches the same entry. To fetch two unique entries, the first entry_id is fed into the second channel:entries tag to exclude that entry_id)

{exp:stash:set 
  parse_tags="yes" parse_depth="4" parse_conditionals="yes" 
  save="yes" replace="no" scope="site"
  }
  // <!-- First get 1 entry from cat1, store the id and entry -->
  {exp:channel:entries channel="news" dynamic="no" limit="1" category="1"}
    {stash:news_cat1_id}{entry_id}{/stash:news_cat1_id}
    {stash:news_cat1_latest}{title}{/stash:news_cat1_latest}
  {/exp:channel:entries}
{/exp:stash:set}

{exp:stash:set 
  parse_tags="yes" parse_depth="4" parse_conditionals="yes" 
  save="yes" replace="no" scope="site"
  }
  // <!-- Fetch an entry from cat2, excluding first found entry_id by
  //       feeding it to chan:entries entry_id  -->
  {exp:channel:entries channel="news" dynamic="no" limit="1" category="2"
    entry_id="not {exp:stash:get name='news_cat1_id'}" parse="inward"
    }
    {stash:news_cat2_latest}{title}{/stash:news_cat2_latest}
  {/exp:channel:entries}
{/exp:stash:set}

// <!-- add the news to the content -->
{exp:stash:append name="content"}
  <div>
    {exp:stash:get name="slideshow"}
    {exp:stash:get name="news_cat1_latest"}
    {exp:stash:get name="news_cat2_latest"}
  </div>
{exp:stash:append}

(edit: stash:get fixed for example)

{exp:stash:get_list} sorting by a numeric column

Having tested {exp:stash:get_list}, I found out that any numeric column used as a reference for sorting is evaluated as a string, not as a number.

So I get something like this in order,

1
10
11
12
...
2
20
21
22
...
3

How do I make it so that it evaluates that column as a number?

{exp:stash:set_list name="message_list_items" parse_tags="yes"}
    {exp:example:message
        conversation_id="{segment_2}"
        limit="{limit}"
        paginate="bottom"
        sort="desc"
    }
        {if '{count}' == 1}
            {stash:opening_tag}
            {!- Some Stuff here --}
            <ol>
            {/stash:opening_tag}
        {/if}
        {stash:message_order}{count}{/stash:message_order}
        {stash:message}
                <li>
                    {!- Some Stuff here --}
                </li>
        {/stash:message}
    {/exp:example:message}
{/exp:stash:set_list}

{exp:stash:get_list
    name="message_list_items"
    {if '{embed:arbitrary_condition}' != 'y'}
        orderby="message_order"
        sort="asc"
    {/if}
}
    {if '{count}' == 1}
        {opening_tag}
    {/if}
    {message_order}
    {message}
{/exp:stash:get_list}
{/ol}

Store entry ids?

Hi,

Is it possible to use Stash for storing/getting a dynamically-generated entry id?

a simplified example of what I'm trying to do looks like this:


{exp:channel:entries channel="my_channel" search:my_field="something" limit="1" orderby="random"}

{exp:stash:set_value name="the_id" type="snippet" value="{entry_id}" parse="inward"}

Some code ...

{/exp:channel:entries}

More code ... then:

{exp:channel:entries channel="my_channel" entry_id="{the_id}"}

Show this ...

{/exp:channel:entries}

Then:

{exp:channel:entries channel="my_channel" entry_id="not {the_id}" orderby="random" limit="5"}

Show the others ...

{/exp:channel:entries}


Any insight would be helpful!

Thanks,

Lauren

Issue parsing {url} variable

It seems that Stash has trouble parsing {url} variables inside a plugin that is inside a stash set tag.

For example:

{exp:stash:set name="member-foursquare-photo"}
<div class="wrap">
        {exp:foursquare_venue:venue_photos venue_id="{member_foursquare_venue_id}" client_id="[removed]" client_secret="[removed]" limit="5"}
        <h3>Venue Photo Data</h3>
        <li>{items}</li>
            <li>ID: {id}</li>               
            <li>URL: {url}</li>
            {source}
                <li>SOURCE NAME: {name}</li>
                <li>SOURCE URL: {url}</li>
            {/source}
            {user}
                <li>USER ID: {id}</li>
                <li>{first_name}</li>
                <li>{last_name}</li>
                <li>{home_city}</li>
                <li>USER IMAGE: <img src="{photo}" /></li>
                <li>{gender}</li>
                <li>{canonical_url}</li>
            {/user}
            <li>{visibility}</li>
        {/items}
        {/exp:foursquare_venue:venue_photos}
    </div>  
{/exp:stash:set}

All of the variables parse correctly, except any of the {url} variables. If the stash tags are removed, the {url} variables are parsed correctly. Any ideas what might be causing this?

Get_list shows/leaves empty tags

The following stash leaves {kolom2} on the site when the field is empty (e.g. an empty wygwam field)

{exp:stash:set_list name="pagina_tekst" parse_tags="yes" parse_depth="2" save="no" replace="yes" scope="site" parse="inward"}
    {exp:channel:entries channel="pagina"
        disable="category_fields|member_data|pagination"
        dynamic="no"
        url_title="contact-dank-u"
    }
    {stash:kolom1}{kolom1}{/stash:kolom1}
    {stash:kolom2}{kolom2}{/stash:kolom2}
    {/exp:channel:entries}
{/exp:stash:set_list}

{exp:stash:get_list name='pagina_tekst' prefix="pageprefix"}
    {kolom1}
    <hr>
    {kolom2}
    {if pageprefix:no_results}
      Not found
    {/if}
{/exp:stash:get_list}

Production Version

Am I correct in saying that their is no version suitable for production use between 2.1 and the current release? I would really like to use the stash embed for speed reasons, but that is only possible after 2.2.

Readme update

Mark no issue just ran across something in the docs that might need amending:

In your advanced usage 2 example you are using {/exp:structure_channel:entries} to close a {exp:channel:entries} tag.

Cheers
Dan

Hook request

Hi,

I'm the developer of the BiopsEE extension. BiopsEE tricks ExpressionEngine into using an extended version of the EE_Template class to do it's thing. Unfortunately that means when Stash is in use, it is unable to access the tag parameters that the module is being called with, leading to errors and empty output from {exp:stash:get}.

I'd like to send a pull request over to add a hook to the _load_EE_TMPL method in mod.stash.php that allows a different class to be used for instantiation. Would this be acceptable?

Typo in documentation for get_list, section, under single variables?

In this section, on exp:stash:get_list, under the single variables bullet list: https://github.com/croxton/Stash#single-variables

last bullet item reads: {switch="one|two|three"} - this variable permits you to rotate through any number of values as the list rows are displayed. The first row will use "one", the second will use "two", the third "option_three", the fourth "option_one", and so on.

Shouldn't it be third "three", the fourth "one"? I don't see where option-underscore (option_) comes from.

Trying to embed an in-line svg file with {exp:stash:embed} or {exp:stash:get file="yes"} fails

Hi Mark,

I'd like to embed (or 'get', not sure which is better) as section of inline svg code into my template using Stash. However, the parser assumes it will have the html extension, and cannot read it.

I have currently worked round the by adding svg to the permitted file extensions for Stash embeds in your core code:

array('html', 'md', 'css', 'js', 'rss', 'xml', 'svg');

but then I get the following error message 'Parse error: syntax error, unexpected T_STRING' in ... libraries/Functions.php(680) : eval()'d code on line 534

So I have two questions:

  1. Is there any way to embed in-line svg without hacking your core?
  2. Is there a way to get the svg code read without triggering a php error?

UPDATE: I've solved the parse error message by running the module updates. So just question one remains. I guess I could just rename the svg file to html, but that feel's a bit uncomfortable.

UPDATE 2: I've now seen you can add svg as a permitted file type via the Stash config variables. So in other works all queries resolved!

Thanks in advance, Nye

Faulty get_list() limit/offset logic

If you have a Stash list of 31 items, in 3 cols:

<ul>
{exp:stash:get_list name="list_name" limit="1/3" orderby="title" sort="asc"}
    <li>Item {absolute_count}/{absolute_results}</li>
{/exp:stash:get_list}
</ul>

<ul>
{exp:stash:get_list name="list_name" limit="1/3" offset="1/3" orderby="title" sort="asc"}
    <li>Item {absolute_count}/{absolute_results}</li>
{/exp:stash:get_list}
</ul>

<ul>
{exp:stash:get_list name="list_name" offset="2/3" orderby="title" sort="asc"}
    <li>Item {absolute_count}/{absolute_results}</li>
{/exp:stash:get_list}
</ul>

You will get the same list item at the bottom of the second list and the top of the third.

Faulty logic seems to in the Stash::_parse_fraction() method.

Limit for 1st list is calculated as ceil((1/3)_31) = 11
Limit/offset for 2nd list is calculated as ceil((1/3)_31) = 11
Offset for 3rd list is calculated as ceil((2/3)*31) = 21

Causing a total of 32 items to be shown:
http://cl.ly/image/0J2Y2i3T0F05

Separator option for appending?

Hi Mark. I was thinking it would be cool if there was a separator option when appending variables so one could easily create an EE list, e.g. 1|2|3 or open|closed. I managed to hack it into the plugin for my usage, but it's honestly very hack and is banking on only the last {exp:stash:append_value} call of having the separator variable defined.

Here is how I changed it:

EE->TMPL->fetch_param('separator', NULL) ) { $this->_stash[$name] .= $this->EE->TMPL->tagdata ? $this->EE->TMPL->tagdata . $separator : ''; } else { $this->_stash[$name] .= $this->EE->TMPL->tagdata; } ``` if ( $this->EE->TMPL->fetch_param('cleanup') == 'yes' ) { $this->_stash[$name] = trim($this->_stash[$name], $separator); } } else { $this->_stash[$name] = $this->EE->TMPL->tagdata.$this->_stash[$name]; } ``` ?>

And it works in this use case, which is fine for me, but not entirely flexible.

{if type}
{exp:stash:append_value name="category_filter" parse="inward" value="{type}" type="snippet" separator="&"}
{/if}
{if add_on}
{exp:stash:append_value name="category_filter" parse="inward" value="{add_on}" type="snippet" separator="&"}
{/if}
{if severity}
{exp:stash:append_value name="category_filter" parse="inward" value="{severity}" type="snippet" separator="&" cleanup="yes"}
{/if}

I also didn't realize you could grab the global_vars array by reference and modify it in a plugin. I always thought that array was taken into account before plugin code runs. Thanks for the lesson ;)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.