Access node information is essential to working with XSLT in
Umbraco.
Eventually you may want to acces the following types of
nodes:
- Content nodes
- Media nodes
- Member nodes
Accessing attributes and elements of these nodes are essentially
done in the same way once you've got the node.
Node attributes are available using the '@' character, e.g. this code will display
the nodeName attribute of the current node.
<xsl:value-of select="@nodeName"/>
All available attributes for the different node types, as well
as some example values, are shown in the tables in the last
section of this page.
Content nodes
Content nodes contain a set of standard attributes as well as
your custom fields defined in the document type of the node.
Further more content nodes contain child node information (if any
children of the nodes exist).
Document type properties are data elements of the
content node with the alias attribute set to the
property name. These properties can be accessed using syntax
like node/data [@alias = 'MyProperty''. E.g. getting the
PackageMedia document type property of the $currentPage content
node is done like this:
<xsl:variable name="MediaNode" select="$currentPage/data [@alias = 'PackageMedia']"/>
Media nodes
Media nodes contain a set of standard attributes as well as
your custom fields defined in the media type of the node.
Media type properties are data elements of
the media node with the alias attribute set to
the property name. These properties can be accessed
using syntax like node/data [@alias = 'MyProperty''.
E.g. getting the 'umbracoFile' property of the media node with
id $MediaNodeId is done like this:
<xsl:value-of select="umbraco.library:GetMedia($MediaNodeId, 'false')/data [@alias = 'umbracoFile']"/>
Node attributes and example data
An automatically extracted version of the available v4
attributes is dynamically listed here:
Content node attributes:
id | 1087 |
version | 68bb8859-ae13-4ce0-83ea-a1d8eebba38c |
parentID | 1083 |
level | 4 |
writerID | 0 |
creatorID | 0 |
nodeType | 1078 |
template | 1073 |
sortOrder | 2 |
createDate | 2009-02-27T08:06:30 |
updateDate | 2009-09-08T10:52:39 |
nodeName | Accessing node information |
urlName | accessing-node-information |
writerName | Administrator |
creatorName | Administrator |
nodeTypeAlias | UmbracoSnippet |
path | -1,1081,1082,1083,1087 |
Content node data element (Node/data) attributes:
Member node attributes:
id | 1114 |
version | fbe93996-12cf-4273-9677-816483df37c0 |
parentID | -1 |
level | 1 |
writerID | 0 |
nodeType | 1113 |
template | 0 |
sortOrder | 2 |
createDate | 2009-03-02T12:48:59 |
updateDate | 2009-03-02T12:48:59 |
nodeName | dummy |
urlName | dummy |
writerName | Administrator |
nodeTypeAlias | Normal |
path | -1,1114 |
loginName | dummy |
email | dummy@blackpoint.dk |
Media node attributes:
id | 1092 |
version | 60968aad-c6d2-4e54-81b5-56a174d91ee2 |
parentID | 1091 |
level | 2 |
writerID | 0 |
nodeType | 1077 |
template | 0 |
sortOrder | 1 |
createDate | 2009-02-27T08:13:28 |
updateDate | 2009-02-27T08:13:28 |
nodeName | BP.Umb.Dashboard, v3 |
urlName | bp.umb.dashboard,v3 |
writerName | Administrator |
nodeTypeAlias | Package |
path | -1,1091,1092 |