Skip to content

{exp:stash:unset}

Mark Croxton edited this page Jun 21, 2013 · 3 revisions

Unset an existing variable or matching set of variables.

Note: {exp:stash:unset} requires PHP 5.2.3+. Alternatively you can use {exp:stash:destroy}

Parameters

name = [ string | #regex# ]

The name of a variable, or a regular expression matching part or all of the variable name (optional).

context = [ string ]

The variable namespace (optional).

type = [ variable | snippet ]

The type of the variable you wish to unset (optional, default is 'variable').

scope = [ local | user | site | all ]

The variable scope (optional, default is determined by the stash_default_scope config value). Pass all to unset variables regardless of their scope.

bundle = [string]

Limit the unset to variables in a named bundle (optional)

flush_cache = ['yes'|'no']

Delete the variable value from the database, if it has been saved (optional, default is 'yes').

Examples

{!-- unset 'my_var' --}
{exp:stash:unset name="my_var"}

{!-- unset 'my_var' snippet --}
{exp:stash:unset name="my_var" type="snippet"}

{!-- unset all vars which start with 'my_' --}
{exp:stash:unset name="#^my_#"}

{!-- unset all user-scoped variables --}
{exp:stash:unset scope="user"}

{!-- unset all site-scoped variables in the 'static' bundle --}
{exp:stash:unset scope="site" bundle="static"}

{!-- unset all variables with the name 'my_var' in the @URI context --}
{exp:stash:unset context="@URI" name="my_var"}

{!-- unset all variables that begin with 'my_' in the 'my_context' context --}
{exp:stash:unset name="#^my_context:my_#"}
Clone this wiki locally