Written by     For umbraco versions: All

Reference
A look at the mysterious macro parameter types and their syntax.

Chapters

An overview of all the macro parameters

Okey so in the previous steps we looked at working with 2 of the most common parameters. The "text" type and the "contentTree" type.

For this exemple I've setup a simple xslt macro with all the different types of parameters attached so we can get a nice overview of how all the data looks like:

step3

I've then inserted it into a template, filling out all the information so the umbraco macro tag inserted in the template will look like this big chunk of code:

<?UMBRACO_MACRO macroAlias="RenderProperties" bool="1" 
contentAll="1060" contentPicker="1060" contentRandom="1060"
contentSubs="1060" contentTreee="1060" contentType="1078"
contentTypeMultiple="1047, 1045, 1046" mediaCurrent="1161"
number="123" propertyTypePicker="description"
propertyTypePickerMultiple="cbAdresse, cbLeveringAdresse, cbAdresse2"
tabPicker="intro" tabPickerMultiple="betalingsform, content, contents"
text="text" textMultiLine="text multi line">
</?UMBRACO_MACRO>

To get a quick view of how the xml data looks like I've created a xslt macro which will return all the xml with this simple xpath:

<xsl:copy-of select="/macro"/>

The xml of all the parameters

Okey so now we have a sample of each type of parameter you can add to a xslt macro. The raw xml send to the xslt file looks like this:

tabPickerMultiple - a comma separated list of selected tab captions

<tabPickerMultiple>
betalingsform, content, contents
</tabPickerMultiple>

tabPicker - the caption of the selected tab

<tabPicker>intro</tabPicker>

textMultiline - a text string.

<textMultiLine>
text multi line
</textMultiLine>

contentPicker - the ID of the selected node as a single integer.

<contentPicker>1060</contentPicker>

mediaCurrent - the xml of the selected media item

<mediaCurrent>
<node id="1161" version="98382b8d-2383-4344-b2ec-10b2e62a3ac9"
parentID="-1" level="1" writerID="0" nodeType="1032"
template="0" sortOrder="2" createDate="2007-07-03T11:49:34"
updateDate="2007-07-03T11:49:34" nodeName="hello"
urlName="hello" writerName="Administrator" nodeTypeAlias="Image"
path="-1,1161">
<data alias="umbracoFile">/media/857/iphone.mp3</data>
<data alias="umbracoWidth" /><data alias="umbracoHeight" />
<data alias="umbracoBytes">63266</data>
<data alias="umbracoExtension">mp3</data>
</node>
</mediaCurrent>

propertyTypePickerMultiple - a comma separated list of selected property type aliases

<propertyTypePickerMultiple>Adresse, LeveringAdresse</propertyTypePickerMultiple>

contentTree - the xml of the selected node and it's child nodes

<contentTreee nodeID="1060">
<node id="1060" version="a27d163f-828e-420e-9758-6db52acae492" 
parentID="-1" level="1" writerID="0" creatorID="0" nodeType="1047"
template="1039" sortOrder="3" createDate="2007-06-21T14:09:32"
updateDate="2007-06-21T14:10:43" nodeName="DE Frontpage"
urlName="de-frontpage" writerName="Administrator"
creatorName="Administrator"
nodeTypeAlias="wwFrontpage" path="-1,1060"> <data alias="bodyText">...</data> <data alias="headerImage">/media/21/header.png</data> </node> </contentTreee>

contentTypeMultiple - a comma separated list of selected content type aliases

<contentTypeMultiple>1047, 1045, 1046</contentTypeMultiple>

contentRandom - the xml from a random child node of the selected node.

<contentRandom>
<node id="1064" version="ae51fa12-e2a1-4456-8e97-1d2d4ef959e1"
parentID="1060" level="2" writerID="0" creatorID="0"
nodeType="1046" template="1041" sortOrder="3"
createDate="2007-06-21T14:09:33" updateDate="2007-06-21T14:10:43"
nodeName="News" urlName="news" writerName="Administrator"
creatorName="Administrator" nodeTypeAlias="wwNews"
path="-1,1060,1064">
<data alias="bodyText">...</data>
</node>
</contentRandom>

text - a text string

<text>text</text>

number - an integer

<number>123</number>

contentAll - doesn't work but included for reference anyway

<contentAll />

propertyTypePicker - the alias of the selected property type

<propertyTypePicker>description</propertyTypePicker>

contentType - the alias of a selected content type as a string

<contentType>1078</contentType>

bool - A true/false value - returned as either 1 or 0

<bool>1</bool>

Conclusion

Okey that was a walkthrough of the different types of parameters you can use in a xslt macro. If you are new to the concept of xslt and xpath, it's very important that you keep in mind that the above reference is what the paramaters will look like in their raw form (using xsl:copy-of). If you just want the value of a simple parameter (like text, number and bool) you can simple use xsl:value-of instead which will only return the value. ("Hello world" instead of "<text>hello world</text>")

Also keep in mind that the above xml syntax is because of the aliases of my parameters. A text parameter with the alias "myName" would return the raw xml "<myName>hello world</myName>" not "<text>Hello world</text">


Brilliant umbraco hosting provided by FAB-IT