You don't need to set $currentPage as the root node of the website you can simply modify the XPATH so that it finds the root node (from the current page) i.e.
<xsl:for-each select="$currentPage/ancestor::root/node [@nodeTypeAlias = 'doc_pages' and string(data [@alias='umbracoNaviHide']) != '1']">
This will now always (wherever you are in the site) list out the child pages of the root node.
I think this is what you are after?
Why not check out my flexible navigation package for an example of navigation XSLT which does similar to what you are looking for I think.
Top navigation is devided into two parts ... one displays all doc_pages and one displays tools_pages.
So I have to use template called list subpages by document types .....
On homepage everything displays fine ... then if click on page1 .... your first answer worked ... now if I click on page under Page1 (left-panel) ... i wont get the navigation on the page.
<xsl:for-eachselect="$currentPage/ancestor::root/node [@nodeTypeAlias = 'doc_pages' and string(data [@alias='umbracoNaviHide']) != '1']">
web1 (doc_pages) (web1mweb2,web3 uses a master template)
web2 (tools_pages)
subweb1 (subweb1,subweb2,subweb3 also uses same master template)
subweb2
subweb3
web3 (content_pages)
Fo home page navigation I am uing separate macro.
For other pages using different macro. From homepage when I move to web1 ... web 1 opens in master template ans then as u said $currentpage/../node works fantastic. But the prob is when I click for subweb1 which also uses same masterpage does not display navigation. I tried the xpath $currentpage/ansector::root/node .... this is not working. DO you suggest anything.
How to get ParentPage name in "List Subpages by document type template"
Hi all,
Thanks in advance.
I am using below template to get list of subpages by document types.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/>
<!-- Input the documenttype you want here -->
<xsl:variable name="documentTypeAlias" select="string('weblogItem')"/>
<xsl:template match="/">
<link rel="stylesheet" href="/css/home_navigation.css" />
<!-- The fun starts here -->
<ul id="list-nav">
<xsl:for-each select="$currentPage/node [@nodeTypeAlias = 'doc_pages' and string(data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
Now my requirement is ...... I want to descent from parent node of the current page and not the current page. Please copy the require XSLT for me.
in for-each loop ... i want parent of currentpage and then descent down.
This should work:
$currentPage/../node
T
This is a helpful page -> http://umbraco.org/documentation/books/xslt-basics/xpath-axes-and-their-shortcuts
Hi Tim,
This worked for me. Thanks a lot.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/>
<!-- Input the documenttype you want here -->
<xsl:variable name="documentTypeAlias" select="string('weblogItem')"/>
<xsl:template match="/">
<link rel="stylesheet" href="/css/home_navigation.css" />
<!-- The fun starts here -->
<ul id="list-nav">
<xsl:for-each select="$currentPage/node [@nodeTypeAlias = 'doc_pages' and string(data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
I have one more question. Can I set the value for the $currentPage is always the root node of the website.
Hi,
You don't need to set $currentPage as the root node of the website you can simply modify the XPATH so that it finds the root node (from the current page) i.e.
This will now always (wherever you are in the site) list out the child pages of the root node.
I think this is what you are after?
Why not check out my flexible navigation package for an example of navigation XSLT which does similar to what you are looking for I think.
Tim
Hi Tim,
<xsl:for-each select="$currentPage/ancestor::root/node [@nodeTypeAlias = 'doc_pages' and string(data [@alias='umbracoNaviHide']) != '1']">
this is not working ....
Let me tell you the website structure::
Homesite ..... template (Home_page)
Page 1
Hi Tim
Website structure :
Homesite .... (Home_page)
page1 ...... (docs_pages)
page 2 ..... (docs_pages)
tool 1 .... (tools_pages )
tool2 ... (tools_pages)
Top navigation is devided into two parts ... one displays all doc_pages and one displays tools_pages.
So I have to use template called list subpages by document types .....
On homepage everything displays fine ... then if click on page1 .... your first answer worked ... now if I click on page under Page1 (left-panel) ... i wont get the navigation on the page.
<xsl:for-each select="$currentPage/ancestor::root/node [@nodeTypeAlias = 'doc_pages' and string(data [@alias='umbracoNaviHide']) != '1']">
is not working ... is syntax correct.
HI Tim,
let me put it in simple way.
Honesite (home_page)
web1 (doc_pages) (web1mweb2,web3 uses a master template)
web2 (tools_pages)
subweb1 (subweb1,subweb2,subweb3 also uses same master template)
subweb2
subweb3
web3 (content_pages)
Fo home page navigation I am uing separate macro.
For other pages using different macro. From homepage when I move to web1 ... web 1 opens in master template ans then as u said $currentpage/../node works fantastic. But the prob is when I click for subweb1 which also uses same masterpage does not display navigation. I tried the xpath $currentpage/ansector::root/node .... this is not working. DO you suggest anything.
is working on a reply...