bannerbannerbannerbannerbanner
Jova wiki   tid   Login/Logout

Navigation





Search the wiki
»

PoweredBy

Page History: Umbraco XSLT-exempel

Compare Page Revisions

Compare revision to revision


List of revisions

« Older Revision - Back to Page History - Newer Revision »


Page Revision: 2011/04/09 16:57


Examples showing changes in XSLT

Getting the Document Type for $currentPage

New version:
 <xsl:value-of select="local-name($currentPage)" />
Replaces old version:
<xsl:value-of select="$currentPage/@nodeTypeAlias" />

Selecting a certain document type



For Each child node

New version using /* to select all nodes below this and @isDoc to select documents only:
 <xsl:for-each select="$currentPage/* [@isDoc]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/node">
</xsl:for-each>

For Each child node of a specfic Document Type Alias

New version:
 <xsl:for-each select="$currentPage/NewsItem">
</xsl:for-each>
Or if you have a property with the same name, use @isDoc to get document:
 <xsl:for-each select="$currentPage/NewsItem [@isDoc]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/node [@nodeTypeAlias='NewsItem']">
</xsl:for-each>

For Each child node excluding a specfic Document Type Alias

New version:
 <xsl:for-each select="$currentPage/*[not(self::NewsItem)]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/node [@nodeTypeAlias!='NewsItem']">
</xsl:for-each>

For Each child node via a selectable source

This example shows you how to list childnodes from the nodeID of the contentpicker.
New version:
 <xsl:param name="Source" select="$currentPage/mySource" />
<xsl:for-each select="umbraco.library:GetXmlNodeById($Source)/DocType">
</xsl:for-each>
Replaces old version:
<xsl:param name="Source" 
           select="umbraco.library:GetXmlNodeById($currentPage/data 
           [@alias='mySource'])" />
<xsl:for-each select="$Source/node"></xsl:for-each>

For Each node of a specfic Document Type Alias

This example walks upto the top level node and then looks through all child nodes. Expensive!
New version:
 <xsl:for-each select="$currentPage/ancestor-or-self::Home//MyDocumentType [@isDoc]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/ancestor-or-self::node 
                      [@nodeTypeAlias='Home']//node [@nodeTypeAlias='MyDocumentType']">
</xsl:for-each>

Examples showing changes in XSLT

Getting the Document Type for $currentPage

New version:
 <xsl:value-of select="local-name($currentPage)" />
Replaces old version:
<xsl:value-of select="$currentPage/@nodeTypeAlias" />

Selecting a certain document type

New version, simple form:
<xsl:for-each select="$currentPage/subPage">

For Each child node

New version using /* to select all nodes below this and @isDoc to select documents only:
 <xsl:for-each select="$currentPage/* [@isDoc]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/node">
</xsl:for-each>

For Each child node of a specfic Document Type Alias

New version:
 <xsl:for-each select="$currentPage/NewsItem">
</xsl:for-each>
Or if you have a property with the same name, use @isDoc to get document:
 <xsl:for-each select="$currentPage/NewsItem [@isDoc]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/node [@nodeTypeAlias='NewsItem']">
</xsl:for-each>

For Each child node excluding a specfic Document Type Alias

New version:
 <xsl:for-each select="$currentPage/*[not(self::NewsItem)]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/node [@nodeTypeAlias!='NewsItem']">
</xsl:for-each>

For Each child node via a selectable source

This example shows you how to list childnodes from the nodeID of the contentpicker.
New version:
 <xsl:param name="Source" select="$currentPage/mySource" />
<xsl:for-each select="umbraco.library:GetXmlNodeById($Source)/DocType">
</xsl:for-each>
Replaces old version:
<xsl:param name="Source" 
           select="umbraco.library:GetXmlNodeById($currentPage/data 
           [@alias='mySource'])" />
<xsl:for-each select="$Source/node"></xsl:for-each>

For Each node of a specfic Document Type Alias

This example walks upto the top level node and then looks through all child nodes. Expensive!
New version:
 <xsl:for-each select="$currentPage/ancestor-or-self::Home//MyDocumentType [@isDoc]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/ancestor-or-self::node 
                      [@nodeTypeAlias='Home']//node [@nodeTypeAlias='MyDocumentType']">
</xsl:for-each>

Using a macro parameter to get a document type property

New version:
 <xsl:value-of select="$currentPage/* [name() = $myMacroParameter and not(@isDoc)]" />
Replaces old version:
<xsl:value-of select="$currentPage/data [@alias=$myMacroParameter]" />

ScrewTurn Wiki version 3.0.4.560. Some of the icons created by FamFamFam.