parse order of the host template: at the start, inline with {tags} or, like EE embeds, near the end of template parsing. They can be parsed after retrieval from the cache (like EE embeds), before being cached or at both stages. Non-caching regions can be escaped. They can be nested, but unlike EE embeds you can pre-parse the parent template to assemble a single compiled cache of all child templates. Stas embed v EE embed
OR {stash:embed:foo.js} stash_templates/foo/bar.html {stash:embed context="foo" name="bar"} OR {stash:embed:foo:bar} Passing variables {stash:embed:foo:bar stash:my_var="value"} Basi embe synt
parse_stage="set" Read the file and parse it immediately, then cache the rendered result. Subsequent retrievals return the cache. parse_stage="get" (default) Read the file and cache the un-parsed template code to the database. Parsing occurs on subsequent retrievals. parse_stage="both" Do both the above. Use {stash:nocache} to escape regions so they remain unparsed during SET and are parsed on GET. Pars stag
| {/exp:channel:entries} {stash:embed:bar stash:message="The time is"} {!-- stash_templates/bar.html --} {stash:message}: {stash:nocache}{current_time format="%Y %m %d %H:%i:%s"}{/stash:nocache} {!-- cached instance "foo" created on SET, saved to db: --} My entry 1 | My entry 2 | My entry 3 The time is: {current_time format="%Y %m %d %H:%i:%s"} {!-- final output on GET: --} My entry 1 | My entry 2 | My entry 3 The time is: 2013 11 14 15:40:30
host template. process="start" Embed the template before any other variables and tags in your template are parsed (similar to a snippet). process="inline" Embed the template in the natural parse order of the template (similar to a tag). process="end" (default) Embed the template at the end of template parsing after other tags and variables have been parsed (similar to an EE embed). Proces
process, determine the order in which they are parsed. parse_depth="X" (4) How many layers deep to parse the template. replace="yes|no" (no) When yes, cached instances of a template are regenerated from the original file every time. Can be overridden globally with $assign_to_config['stash_file_sync']. bundle="my_bundle" ("default") Categories for Stash variables - create your own in Mustash. Tunin embed
for content. ViewModel template that captures/caches structured data, populates variables with content, and injects partials containing localised formatting into blocks on demand. ViewModels, partials and wrappers are decoupled. Mode -View ViewMode
{exp:stash:pg_title}My blog{/exp:stash:pg_title} {!-- inject the 'list' partial into 'pg_content' block --} {exp:stash:set_value name="pg_content" value="{exp:stash:embed:views:_list}"} {!-- set a list of blog entries for the partial to render --} {exp:stash:set_list name="list_items" parse_tags="yes"} {exp:channel:entries channel="blog" dynamic="no"} {stash:item}{title}{/stash:item} {/exp:channel:entries} {/exp:stash:set_list}
and presentation layer can be swapped on the fly. Cache data in a structured form and re-use with different formatting and without extra overhead. DRY, legible code helps you maintain a sane codebase. Mode -View ViewMode Pros Routing is still not within the content manager's control. Hardcoded page meta data. Cons
your site and defines placeholders and blocks that child templates can override. A base viewModel template that sets up common variables and default content, and loads child viewModel templates on demand. Optional: a base channel (or channels sharing a fieldgroup) to build the URI structure of your site. Child viewModels and child views are discrete, self-contained, reusable modules. Templat Inheritanc
partials are self-contained modules that can be combined and re-used. Use the Stash embed compile effect for progressive caching. Permits Structure-like template control but with native template_group/template routing. Templat Inheritanc Pros Complex; best for large projects with many moving parts. Cons
navigational elements, footers, sidebars and other reusable, globally visible page elements (scope="site"). Addressable pages: the unique output of individual pages in your site, where the URI alone is sufficient to generate all possible interaction states ("URI addressibility"). Non-global fragments: Partials that generate output that is specific to the URI or user. Non-addressable pages: where the URI of a page alone is not sufficent to determine it's interaction state. E.g. forms that POST data, shopping carts, 404 pages.
site so that all interaction states are represented by a unique URI. Stay DRY: separate out commonly used global page fragments into snippets, Low Variables or Stash embeds. Where possible cache structured data, not marked-up data, so you can re-use the data with different markups. Group like items: use context and/or bundles to create groups of related cached items, so that they can be targetted for cache-breaking. Use layers: Use fragment-caching inside page-caching to allow for progressive cache rebuilds and avoid ‘stampedes’. Cach plannin
for a single entry --} {exp:channel:entries channel="blog" limit="1"} {exp:stash:set} {stash:pg_title}{title}{/stash:pg_title} {stash:pg_intro}{cf_blog_intro}{/stash:pg_intro} {stash:pg_body}{cf_blog_body}{/stash:pg_body} {/exp:stash:set} {/exp:channel:entries} {!-- this will be escaped --} {stash:nocache} Hi, {screen_name} {/stash:nocache} {/exp:stash:cache}
>10 times greater concurrency than through PHP. Stati cachin Pros Pages cannot contain escaped regions that remain dynamic*. Cache never expires. Needs Mustash for cache-breaking. Cons Use in combination with Varnish and Edge Side Includes (ESI). *Experimental/advanced use
{!-- {exp:stash:cache} static caching --} {exp:stash:cache bundle="blog" process="static"} <h1>Page to cache</h1> {/exp:stash:cache} {!-- Or use this tag ONCE anywhere in your template --} {exp:stash:static}
and static file caches. Flush caches: Flush cache globally, by scope or bundle. Bundles: Create and edit your own bundles. Rules: Setup cache-breaking rules for core and third-party modules. Target specific bundles, groups and patterns. Web API: endpoint with custom hooks to trigger rules. Access permissions: limit access by member group. Plugins: extensible architecture for plugin developers Mustas – ke feature
control panel. Group Limit rule to parent group of the item being edited (e.g. channel). Bundle Limit rule to variables in a particular Stash 'bundle' (category). Scope Limit rule to variables with the selected visibility (site, or user). Pattern Limit rule to variables matching a string or regular expression. Definin rule
E.g. 'entry_submission_end' - triggered when an entry is edited. Third-party module hooks Low Reorder, Low Variables, Navee, Structure, Taxonomy + more. Web API custom hooks User-defined hooks for use as an URL endpoint, e.g. http://mysite.com/?ACT=27&key=12345test&hook=my_hook Recursive hooks Hooks that are triggered when Stash caches are deleted, so external caching layers can be flushed. E.g. Varnish.
the cached page where the name matches the channel and url title of the entry that was just edited. E.g. 'blog/my_story'. Clear variables in the 'Navigation' bundle when the 'Main menu' tree is updated in Taxonomy.
a common nonemaclature for template placeholders. Use template design patterns to separate logic from markup. Modularize your code into discrete viewmodels and partials, so that it less closely coupled and more re-usuable. Plan for addressability when designing your URIs. Avoid stampedes by caching in layers: global fragments underneath full-page caching. Organise your cached variables into bundles and design granular cache-breaking rules. Summar