-
Notifications
You must be signed in to change notification settings - Fork 20
Bundles
Bundles are categories for variables. There are three default bundles: default, template and static, and you are able to create your own simply by specifying a name with the bundle=""
parameter when creating variables, lists and embeds.
If you are using Mustash, you can create and manage your bundles in the Control Panel interface.
This is the default place for all variables and lists that you create in your templates using the set/get syntax.
This is the default bundle for all stash templates embedded with the {stash:embed}
tag.
This is the default bundle for all variables captured by the {exp:stash:static}
tag.
{exp:stash:set name="foo" bundle="my_custom_bundle"}bar{/exp:stash:set}
The {exp:stash:bundle}
tag can be used to save a group of variables into a single variable in a defined bundle. This is more efficient when saving a large number of form variables.
{!-- set a static context for the form values, which we can reference as '@' --}
{exp:stash:context name="my_search_form"}
{!-- register user-submitted values form the $_POST array, validate, and save to the 'form' bundle --}
{exp:stash:bundle name="form" context="@" refresh="10" parse="inward"}
{exp:stash:get dynamic="yes" type="snippet" name="orderby" default="entry_date" match="#^[a-zA-Z0-9_-]+$#"}
{exp:stash:get dynamic="yes" type="snippet" name="sort" default="asc" match="#^asc$|^desc$#"}
{exp:stash:get dynamic="yes" type="snippet" name="category" default="" match="#^[a-zA-Z0-9_-]+$#"}
{/exp:stash:bundle}
{!-- now we could use like this in an embedded view template --}
<input name="orderby" value="{@:orderby}">
{!-- and if we wanted to populate a select menu --}
Bundles can be a useful when you need to clear a group of cached variables that are related in some way.
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