x First time here? Check out the FAQ

Come work for Umbraco - The Umbraco HQ are hiring Project managers, .NET developers and DevOps people!

Advanced macro parameter syntax

    Instead of just using hard-coded values, it is also possible to pass values from the current, the request collection and cookies to a macro.

    This is done by using a special syntax, currently known so far as as "the bracket syntax" (better name will be introduced in Umbraco 5.0)

    Example:

    Umbraco Version 3:
    <?UMBRACO_MACRO macroAlias="RenderProperties" pageValue="[#bodyText]" />

    Umbraco Version 4:
    <umbraco:macro alias="RenderProperties" pagevalue="[#bodyText]" runat="server"/>

    This will pass the current page's property with the alias "bodyText"

    Syntax:

    Insert page value: [#propertyAlias]

    Insert recursive page value: [$propertyAlias]

    Insert cookie value: [%cookieValueKey]

    Insert value from request collection: [@requestValueKey]

    Test for multiple values

    In some cases there might be several different values you would like to send to your macro, and depending on the document type in use, they might have different values.

    To avoid sending a blank value to the macro you can test several values by comma separating them like this:

    <umbraco:macro value="[#propertyAlias],[#propertyAlias2],my static string" />

    the above sample look up the current page the macro is executed on, and tries to look up the property with the alias "propertyAlias", if that value is empty it will try "otherPropertyalias" and finally if no value is found fall back to the static value "my static string" specified on the macro.  (For Umbraco versions up to 4.0.3 do not put spaces before, or after, each comma)