-
Notifications
You must be signed in to change notification settings - Fork 20
{exp:stash:get}
Retrieve a variable value.
{exp:stash:get name="my_var"}
The name of your variable (required)
The type of variable to retrieve (optional, default is 'variable').
Is the variable set for the current page only, for the current user, or globally (set for everyone who visits the site) (optional, default is 'user'). Note: use the same scope that you used when you set the variable.
If the variable was defined within a context, set it here Tip: you can also hardcode the context in the variable name, and use '@' to refer to the current context:
{exp:stash:get name="title" context="@"}
{exp:stash:get name="@:title"}
{exp:stash:get name="news:title"}
The Bundle the variable is assigned to (optional, default is 'default').
Look in the $_POST and $_GET superglobals arrays, for the variable (optional, default is 'no'). If Stash doesn't find the variable in the superglobals, it will look in the uri segment array for the variable name and takes the value from the next segment, e.g.: /variable_name/variable_value
When using dynamic="yes", do you want to store the value we have retrieved in the database so that it persists across page loads? (optional, default is 'no')
When using save="yes"
, this parameter sets the number of minutes to store the variable (optional, default is 1440 - or one day)
When using dynamic="yes"
or file="yes"
, do you want the variable to be overwritten if it already exists? (optional, default is 'yes')
Default value to return if variable is not set or empty (optional, default is an empty string). If a default value is supplied and the variable has not been set previously, then the variable will be set in the user's session. Thus subsequent attempt to get the variable will return the default value specified by the first call.
Do you want to output the variable or just get the variable quietly in the background? (optional, default is 'yes')
When using MSM specify the site id here (optional). By default, the site_id of the site currently being viewed will be used. This parameter allows you to share variables across multiple sites.
When in the parse order of your EE template do you want the variable to be retrieved (default='inline')
Retrieve the variable in the natural parse order of the template (like a standard EE tag)
Retrieve the variable at the end of template parsing after other tags and variables have been parsed
Determines the order in which the variable is retrieved when using process="end". Lower numbers are parsed first (default="1")
Remove whitespace and linebreaks from the variable? (optional, default is 'no').
Strip HTML tags from the returned variable? (optional, default is 'no').
Strip curly braces ( { and } ) from the returned variable? (optional, default is 'no').
Remove an arbitrary number of characters from the end of the returned string
Return only part of the string designated by the first capture group in a regular expression (optional)
{!-- strip a trailing pipe character --}
{exp:stash:get name="title" filter="#^(.*)\|$#"}
{exp:stash:get name="title"}
Let's say you have a search form and you need to register a form field value and persist it across page views:
{exp:stash:get name="my_form_field_name" type="snippet" dynamic="yes" save="yes" refresh="30"}
In an embedded template we have a {exp:channel:entries}
tag producing a paginated listing of entries:
{exp:channel:entries search:custom_field="{my_form_field_name}" disable="member_data|pagination|categories"}
...
{/exp:channel:entries}
Getting started
Using Stash
Using Mustash
- Mustash
- Installing Mustash
- Managing variables
- Managing bundles
- Cache-breaking rules
- Mustash plugins
- Mustash Varnish plugin
- Mustash plugin development
- Mustash API
Template design patterns
Tag reference
- {exp:stash:set}
- {exp:stash:get}
- {exp:stash:block}
- {exp:stash:set_value}
- {exp:stash:append}
- {exp:stash:append_value}
- {exp:stash:prepend}
- {exp:stash:prepend_value}
- {exp:stash:copy}
- {exp:stash:context}
- {exp:stash:is_empty}
- {exp:stash:not_empty}
- {exp:stash:set_list}
- {exp:stash:get_list}
- {exp:stash:append_list}
- {exp:stash:prepend_list}
- {exp:stash:split_list}
- {exp:stash:join_lists}
- {exp:stash:list_count}
- {exp:stash:unset}
- {exp:stash:flush_cache}
- {exp:stash:bundle}
- {stash:embed}
- {exp:stash:extend}
- {exp:stash:parse}
- {exp:stash:cache}
- {exp:stash:static}
- {exp:stash:finish}
- {exp:stash:not_found}
- Short tag syntax
- Using Stash methods in your own add-ons