Important: special values for glue & separator parameters
Important: using the "random" parameter to avoid plugin tag caching
This tag will set a variable's value. It will overwrite anything that may already exist in the variable.
{exp:string:set name="title" default="{title}"}{blog_page_title}{/exp:string:set}
This tag will add new text to the end of an existing variable. If the variable doesn't exist or is empty, this tag will act like the exp:string:set tag (separator & glue will only be inserted if the variable has text in it already).
This would store the string "Newest Blog Entry | Blog | eMarketSouth" to the "title" variable:
{exp:string:set name="title"}Newest Blog Entry{/exp:string:set}
{exp:string:append name="title" separator="|" glue="SPACE"}Blog{/exp:string:append}
{exp:string:append name="title" separator="|" glue="SPACE"}eMarketSouth{/exp:string:append}
This tag will add new text to the beginning of an existing variable. If the variable doesn't exist or is empty, this tag will act like the exp:string:set tag (separator & glue will only be inserted if the variable has text in it already).
This would store the string "Newest Blog Entry | Blog | eMarketSouth" to the "title" variable:
{exp:string:set name="title"}eMarketSouth{/exp:string:set}
{exp:string:prepend name="title" separator="|" glue="SPACE"}Blog{/exp:string:prepend}
{exp:string:prepend name="title" separator="|" glue="SPACE"}Newest Blog Entry{/exp:string:prepend}
This tag will clear the value of the named variable. Just a single tag, no need to close the pair.
This will clear the contents of the "title" variable:
{exp:string:clear name="title"}
This tag will print the current value of the named variable. As of version 1.2.0 the value of any string variable can be output within this tag pair by putting the variable name in curly braces.
This will print the string stored in the variable "title":
{exp:string:output name="title"}{string}{/exp:string:output}
It is possible to use conditionals within the output tag:
{exp:string:output name="title"}
{if string != ""}
<title>{string}</title>
{if:else}
<title>eMarketSouth</title>
{/if}
{/exp:string:output}
As of version 1.2.0 it is possible to output multiple variables in a single tag pair. This example will output "This is a test":
{exp:string:set name="test1"}This is{/exp:string:set}
{exp:string:set name="test2"}a test{/exp:string:set}
{exp:string:output}
{test1} {test2}
{/exp:string:output}
This short tag can be used as a single tag (not a pair) to print the value of the named variable.
this will print the string stored in the variable "title":
{exp:string name="title"}
ExpressionEngine trims whitespace from parameter values, so in order to use spaces, tabs, newlines, and empty values for glue and separator parameters we need special tokens:
To append a string using a newline "\n" as the separator and an empty string for glue:
{exp:string:append name="demo" separator="NEWLINE" glue="NONE"}test string{/exp:string:append}
ExpressionEngine caches the return value for identical plugin tag calls and silently won't call the plugin the second and subsequent times. This only happens when the parameters and tag data is identical on multiple calls to the same plugin. This does not cause problems for most plugins, but will for this one. As an example, the following code will exhibit the issue:
{exp:string:set name="demo"}testing{/exp:string:set}
{exp:string name="demo"}
{exp:string:append name="demo" separator="SPACE" glue="NONE"}123{/exp:string:append}
{exp:string name="demo"}
It isn't (currently) documented, but ExpressionEngine provides a somewhat awkward - yet effective - solution to this problem. Plugins with the word "random" somewhere in the tag will not be cached and will get executed each time they are called. Just have a blank parameter called "random" in the tag to solve this issue:
{exp:string name="demo" random}

Price: $9.95 per site - buy now at devot-ee.com
Compatibility:
Most Recent Version:
