2022 Developer Survey is open! Take survey.

Hot answers tagged

7 votes
Accepted

Conditional with variable gives php error

The problem with that is that if {parent_id} doesn't get replaced with a number before the conditional is evaluated, then EE will choke because when converted to PHP it becomes: if ({parent_id} == 0)...
user avatar
  • 5,234
5 votes
Accepted

What's the difference between {exp:stash:get name="foo"}, {exp:stash:foo} and {stash:foo}?

{exp:stash:get name="foo"} is a module tag. When the template parser encounters it, it calls the get() method of the 'stash' module class, which returns the value of foo. If foo doesn't exist, an ...
user avatar
  • 5,234
5 votes
Accepted

Using stash to render custom field value rather than string literal

There's no sense in running channel entries twice. This code generates a bunch of stash capture pairs, mapping field names in different channels to a common name: {!-- make a list of your channel ...
user avatar
  • 5,234
5 votes
Accepted

Resource Routing on mutiple URLs

You can do this without a callback function: $config['resource_router'] = array( 'posts' => 'templates/index', 'posts/:category_url_title' => 'templates/cat_entries', 'posts/:...
user avatar
  • 4,002
4 votes
Accepted

Display List of Authors with Latest Post

This solution doesn't use Stash, but you certainly could. This query assumes a broad application, you may be able to simplify it for your needs. The channel_id in the WHERE clauses will need to be ...
user avatar
  • 2,255
4 votes

How to deal with empty stash lists?

If your {exp:stash:get_list} tag is wrapped by another tag pair, then commonly used template variables like no_results are parsed for the parent tag by EE. Add the prefix="my_prefix" parameter to ...
user avatar
  • 5,234
4 votes
Accepted

Stash not overwriting variable - variable stays same after 2nd setting

You use plugin with the same parameters. So EE cached it. Try to add random {exp:stash:set name="sorthead" random} {/exp:stash:set} or change name.
user avatar
  • 5,781
4 votes
Accepted

check if a segment is a number

Using the matches operator, which was added in EE v2.9.0: {if segment_2 ~ "/^\d+$/"} [...] {/if}
user avatar
  • 6,108
3 votes

Can retrieve stash variables inside entry tags, but not outside

The :set tags are not wrong, per se, as you are using the shorthand syntax. However, due to parse order, your 'get' tags are parsing before your 'set' tags since the sets are within the channel ...
user avatar
3 votes
Accepted

Problem with Stash nested lists

You need to use the context parameter and a unique identifier in your nested list. Generally using entry_id is the easiest way to create a relationship between your two lists. Stash {entry_id} in ...
user avatar
3 votes
Accepted

GWCode Categories and Stash set/get_list

I think that by caching both lists, you could reduce queries a little bit further. Easier to add Stash caching / Mustash to the mix too. Something along the lines of: {!-- set stockists list (...
user avatar
3 votes
Accepted

Use backspace parameter on Stash nested get_list

The backspace parameter can be used with {exp:stash:get_list}, however be aware that any trailing whitespace and line breaks will count as 'spaces'. {!-- Desired output - no trailing comma --} ...
user avatar
  • 5,234
3 votes
Accepted

a less expensive way of grouping entries by category

So my experimentation here brought me to Stash. Much more succinct now and gives me everything I need in just 66 queries before caching :) {exp:channel:entries dynamic="no" channel="articles"} {...
user avatar
  • 2,473
3 votes
Accepted

Adding quotes around a parameter causes error?

I believe you're running into problems with the parse order. When you add quotes, recipients becomes a valid parameter but it isn't parsed yet. When you remove the quotes, it becomes an invalid ...
user avatar
3 votes

Stash and Multiple Grid Fields Not Populating

Let me show you how the parser will parse that code before Stash tries to capture it as a list. I'll assume your relationship field only allows you to select a single person: {!-- first grid field --}...
user avatar
  • 5,234
3 votes
Accepted

stash parsing sequence

If you want to understand parse order better, you could have a look at this handy cheat-sheet: originally created by Low, the copy on his site appears to have disappeared, but here is a version of it ...
user avatar
  • 3,562
3 votes
Accepted

Stop stash embed caching file

{stash:embed name="_foobar" replace="yes"}
user avatar
  • 5,234
2 votes
Accepted

how to define the stash embedded template?

As the docs explain, you need to setup your paths in your config: $assign_to_config['stash_file_basepath'] = '/path/to/stash_templates/'; The docs are here: https://github.com/croxton/Stash/wiki/...
user avatar
  • 3,163
2 votes
Accepted

Adding up (SUM) the values of a field in an entries loop

u can use a plugin to do this. I think http://devot-ee.com/add-ons/tally will do the trick. I hope this will help u. Regard's.
user avatar
2 votes
Accepted

Problem importing database - import hangs on exp_stash table

For this particular quandary, this worked: Add this line to the top of the SQL file: SET FOREIGN_KEY_CHECKS = 0; Source: http://devot-ee.com/add-ons/support/stash/viewthread/5700 If you see this ...
user avatar
  • 382
2 votes
Accepted

multiple sliders one page - Stash parse order and Playa

Set your var like this, using the trim parameter to remove whitespace and line breaks from the captured variable: {exp:channel:entries channel="rehab" url_title="{segment_3}" limit="1" require_entry="...
user avatar
  • 5,234
2 votes
Accepted

Multiple Content-Elements with Assets-elements breaking on what seems to be a specific number of images

Open up ft.assets.php file (located at third_party/assets/ft.assets.php), find the method "replace_element_tag" and add this as the first line in that method: $this->EE->load->...
user avatar
2 votes
Accepted

Using Stash to get data from 1 of 2 fields

There's no need for conditionals as the fields are mutually exclusive. With Stash on the inside of channel:entries tags there's also no need for parse_tags or parse_depth since the enclosed content ...
user avatar
  • 4,885
2 votes
Accepted

Display a heading for a stash:get_list if there are more than X entries

You can use a standard EE conditional with (https://github.com/croxton/Stash/wiki/%7Bexp%3Astash%3Alist_count%7D) the stash function list_count to do this. list_count can be used to return the total ...
user avatar
2 votes

Stash snippet problems

Stash variables set to type="snippet" can be accessed in the same way as in previous versions of EE. To demonstrate: {embed="inc/snippet_embed"} {exp:stash:set name="my_snippet" type="snippet"}My ...
user avatar
  • 5,234
2 votes
Accepted

Problem setting a stash variable in a custom module

It should be possible, since that's exactly what I'm doing on my project. Here's my code (which is working): in my __construct() $this->EE = get_instance(); if ( ! class_exists('Stash')) ...
user avatar
  • 1,986
2 votes

Using Stash within Stash to pass an entry_id for Safecracker

If you want to pass a variable in a parameter to any EE template tag, you need to add parse="inward" to the tag. For example: {exp:stash:set name="firm_id"}1{/exp:stash:set} {exp:safecracker channel=...
user avatar
  • 5,234
2 votes
Accepted

exp_stash rows aren't being expired / deleted

Mustash is not the only way but it is the most flexible and granular way I can think of. If you are using Stash for caching, Mustash will be your best solution in terms of establishing cache clearing ...
user avatar
2 votes
Accepted

Call to Stash embed being evaluated inside a Switchee statement when it shouldn't be

I think since your stash embed is set to process on 'start' it will be run first before switchee, which is why you'd see a 'file not found' error if there's no stash file at that location. Try ...
user avatar
2 votes
Accepted

Output x twice then y, then x twice

This builds on CreateSean's answer, since you're using Stash. You'll need a math plugin and in this example I'm using Math from Caddis. {!--set main multi-channel entry list--} {exp:stash:set_list ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible