Skip to content

{exp:stash:block}

Mark Croxton edited this page Jun 8, 2015 · 17 revisions

Retrieve a variable value. If the variable has no value, the tagdata enclosed by the tag is returned.

{exp:stash:block name="my_var"}Fallback value{/exp:stash:block}

{!-- Blocks can also be nested, by appending a unique 4th tagpart to nested tags --}
{exp:stash:block name="page_content"}
	<div class="content">
    	<div class="body" role="main">
        	{exp:stash:block:nested name="page_body"}
            	<h1 class="entry-title">{exp:stash:title}</h1>
            	{exp:stash:body}
        	{/exp:stash:block:nested}
    	</div>
    	<div class="sidebar">
            {exp:stash:sidebar}
    	</div>
	</div>
{/exp:stash:block}

A 4th tagpart can optionally be used in place of the name="" parameter, for a more concise syntax. For example this creates a variable with the context 'block' and the name 'page_content'.

{exp:stash:block:page_content}
	...
{/exp:stash:block:page_content}

Parameters

Accepts the same parameters as {exp:stash:get}, and:

requires = [ variable1 | variable2 | variable3 [|...] ]

Require that one or more variables/blocks exist before the block is output. In the following example the outermost block is only output when the 'alert' variable has a value:

{exp:stash:block:alert_wrap requires="alert"}
<div class="footer-panel">
	<div class="layout-container">
		<div class="layout-row">
			<div class="layout-item col-footer-panel">
				{exp:stash:get name="alert"}
			</div>
		</div>
	</div>
</div>
{/exp:stash:block:alert_wrap}
Clone this wiki locally