SetVar

A function tag used to set the value of a template variable. This tag is considered deprecated in favor of Var, which can be used to both retrieve and assign template variables.

Attributes:

  • var or name

    Identifies the name of the template variable. See Var for more information on the format of this attribute.

  • value

    The value to assign to the variable.

  • op (optional)

    See the Var tag for more information about this attribute.

  • prepend (optional)

    If specified, places the contents at the front of any existing value for the template variable.

  • append (optional)

    If specified, places the contents at the end of any existing value for the template variable.

This page was last updated on 2008-05-23, 17:16.  

Caution! It appears these statements at the beginning of templates outputs blank lines before the Header template. If using any php in the Header before the Doctype, you either need to move the MTInclude Header before the SetVar or put the php code in a MTInclude (or the code itself) before any of the SetVar statements.

MT SetVar (SetVarBlock or SetVarTemplate) should not be creating blank lines in the generated code.

Merv, I've seen similar behavior with SSI statements. I bet it's not the variable statements that output the line breaks; it's the fact that the variable statments are each on their own line.

In other words, the template contains line breaks between each MT variable statement; after the MT tags are used, the line breaks remain!

So run all your variable tags together. It's harder to read and maintain, but removes your excess line breaks:

<mt:SetVar name="foo1" value="bar" /><mt:SetVar name="foo2" value="bar" /><mt:SetVar name="foo3" value="bar" />

Leave a note