I do not know which version of Umbraco you are using, but if you are using version 4.5 or a newer version something like this shold solve your question.
<xsl:template match="/">
<!-- The fun starts here --> <ul> <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul> </xsl:template>
This is from the one of the predefined xslt files i Umbraco. The predefined xslt file has the name. List Sub Pages From Current Page.
From version 4.5 Umbraco comes with a new xml schema. You can read about the difference here:
I have tried to help you find a solution since i write my post. I tested it localhost but I didn´t find the solution before you write that you got it works
So cool you find the solution :)
Youhave the option toselect thecorrect answerby mousingover yourown postoutofkarmapoints. It will helpothers toseethepostthat solvedthe problem.
Listing Sub Pages when on current page
I have a structure like this:
Page 1
> Page 2
> Page 2a
> Page 2b
> Page 3
> Page 3a
>Page 4
I need XSLT that will list all sub pages ONLY if I am on that page.
For example if I am on Page 2 this is how the menu structure should look
> Page 2
> Page 2a
> Page 2b
> Page 3
>Page 4
Please help
Here is what I have so far:
<?xml version="1.0" encoding="utf-8" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="umbraco.library">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:param name="currentPage" />
<xsl:variable name="id" select="$currentPage/@id"/>
<xsl:template match="/">
<ul>
<xsl:apply-templates select="$currentPage/*[@isDoc][not(umbracoNaviHide = 1)]" />
</ul>
</xsl:template>
<!-- Template for generic Document Type -->
<xsl:template match="*[@isDoc]">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</a>
<xsl:if test="$id=$currentPage/parent::node/@id">
<xsl:if test="*[@isDoc][not(umbracoNaviHide = 1)]">
<ul>
<xsl:apply-templates select="*[@isDoc]" />
</ul>
</xsl:if>
</xsl:if>
</li>
</xsl:template>
<!-- No output for these -->
<xsl:template match="*[umbracoNaviHide = 1]" />
</xsl:stylesheet>
Hi Omar,
Welcome to the our.umbraco.
I do not know which version of Umbraco you are using, but if you are using version 4.5 or a newer version something like this shold solve your question.
This is from the one of the predefined xslt files i Umbraco. The predefined xslt file has the name. List Sub Pages From Current Page.
From version 4.5 Umbraco comes with a new xml schema. You can read about the difference here:
http://our.umbraco.org/wiki/reference/xslt/45-xml-schema
Hope this can helps you to solve your question,
/Dennis
Dennis,
I must have stated the question wrong. I need to list all Sibling pages AND only the childern of the current page.
If my menu struture looks like this
Page 1
> Page 2 <--- PAGE THAT I AM ON
> Page 2a
> Page 2b
> Page 3
> Page 3a
>Page 4
Then it should show this:
> Page 2 <--- PAGE THAT I AM ON
> Page 2a
> Page 2b
> Page 3
>Page 4
So I want the sub pages of the Current page AND all its siblings
Thanks
Here is what i have so far. The problem is the second if statment isnt working right
<?xml version="1.0" encoding="utf-8" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="umbraco.library">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:param name="currentPage" />
<xsl:template match="/">
<ul>
<xsl:apply-templates select="$currentPage/../* [@isDoc][not(umbracoNaviHide = 1)]" />
</ul>
</xsl:template>
<!-- Template for generic Document Type -->
<xsl:template match="*[@isDoc]">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</a>
<xsl:if test="*[@isDoc][not(umbracoNaviHide = 1)]">
<xsl:if test="./../@id = $currentPage/@id">
<ul>
<xsl:apply-templates select="*[@isDoc]" />
</ul>
</xsl:if>
</xsl:if>
</li>
</xsl:template>
<!-- No output for these -->
<xsl:template match="*[umbracoNaviHide = 1]" />
</xsl:stylesheet>
I got it to work here is my xslt if anyone want to do the same:
<?xml version="1.0" encoding="utf-8" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="umbraco.library">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:param name="currentPage" />
<xsl:variable name="currentPageId" select="$currentPage/@id"/>
<xsl:template match="/">
<ul>
<xsl:apply-templates select="$currentPage/../* [@isDoc][not(umbracoNaviHide = 1)]" />
</ul>
</xsl:template>
<!-- Template for generic Document Type -->
<xsl:template match="*[@isDoc]">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</a>
<xsl:if test="*[@isDoc][not(umbracoNaviHide = 1)]">
<xsl:if test="./@id = $currentPageId">
<ul>
<xsl:apply-templates select="*[@isDoc]" />
</ul>
</xsl:if>
</xsl:if>
</li>
</xsl:template>
<!-- No output for these -->
<xsl:template match="*[umbracoNaviHide = 1]" />
</xsl:stylesheet>
Hi Omar,
I´am glad to hear that you got it to work.
I have tried to help you find a solution since i write my post. I tested it localhost but I didn´t find the solution before you write that you got it works
So cool you find the solution :)
You have the option to select the correct answer by mousing over your own post out of karma points. It will help others to see the post that solved the problem.
/Dennis
is working on a reply...