<xsl:variablename="items"select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
<!-- The fun starts here --> <xsl:iftest="count($items) > 0"> <ul> <xsl:for-eachselect="$items"> <xsl:iftest="position()=1"> <li> <xsl:attributename="class"> selected </xsl:attribute> <ahref="{umbraco.library:NiceUrl(@id)}"> <xsl:value-ofselect="@nodeName"/> </a> </li> </xsl:if> </xsl:for-each> </ul> </xsl:if> </xsl:template>
If this works as I hope, your first li tag in the 2nd navigation should get the class="selected", and now you can add for example font-weight: bold; in your css to that selector, so the first list element in the 2nd navagation will get bold.
Ihavenottested this myself, but I hope it can help you, if Iunderstoodyourquestioncorrectly.
It works perfectly but it is displying only one child node that to first node remaing nodes are not displayed. I need to select first node every time remaining nodes need to be displayed along with related content.
I'venowhadthe opportunitytotestthexsltwhichIwrotetoyouearlier to day.
I'venowhadthe opportunitytotestthexsltwhichIwrotetoyouearlierin theday. Andwiththiscodebelow I get displyed all childs of the currentpage, and the first li gets the class "selected".
<xsl:template match="/">
<xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/> <!-- The fun starts here --> <xsl:if test="count($items) > 0"> <ul> <xsl:for-each select="$items"> <li> <xsl:if test="position()=1"> <xsl:attribute name="class"> selected </xsl:attribute> </xsl:if> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul> </xsl:if> </xsl:template>
and 2nd level navigation for Community ------ 1.customer 2. Support &
Comany---------- 1. About us,2.Management 3.contact us
when I am select the main menu tab means Community I need !st child ie. customer is selected and display content in customer page same for comapny -- I need About us page
So, if I'm reading this correctly, you don't want a page for Community.... but that's more the title for all of the nodes below in (Customer, Support etc...)...
If that's the case, what you can do is set up an umbraco redirect, so that when they click on Commuity, instead of going to the Community page, they get redirected to the document that you've selected it to go to.
To do this, you should add a content picker to each of your top level pages, and give it the property alias 'umbracoRedirect'. Then for each of your pages, select the first child in that redirect field. Umbraco should automatically redirect to that sub page.
I know this isn't ideal, as it won't automatically pick up your first child item, but if you want to keep that site structure, and still have the functionality you're requesting, then I think it's the best way.
I haven't used this myself, so this is kind of the blind leading the blind. Reading the documentation, umbracoRedirect is supposed to just be a temporary thing, not a permanent thing. Instead, you should try using this package:-
how to select every time first child of the parent node in 2nd level navigation
Hi All,
my code is...
<?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"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
<!-- The fun starts here -->
<xsl:if test="count($items) > 0">
<ul>
<xsl:for-each select="$items">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
It working perfect to me but I need every time I have to select the firstchild node with related content How can I achieve that??
Pls any ideas share with me......
Thanks in adavance...
Hi
Give a try using position. if the position is 1 then select that one only. like
Thanks
Pnima
Can pls explain me in detailed ??
Thanks,
sravani
My menu is like
Community
.customer
.support
When I select the Community by default every time my first child node (customer) is in active.
Thanks
sravani
Hi sravani,
Perhaps you could try something like this.
If this works as I hope, your first li tag in the 2nd navigation should get the class="selected", and now you can add for example font-weight: bold; in your css to that selector, so the first list element in the 2nd navagation will get bold.
I have not tested this myself, but I hope it can help you, if I understood your question correctly.
/Dennis
Thanks Dennis,
It works perfectly but it is displying only one child node that to first node remaing nodes are not displayed. I need to select first node every time remaining nodes need to be displayed along with related content.
Regards,
Sravani
Hi again,
Hello again,
I think I know what the problem is. The problem as I see it, because I came to put the if condition outside the li tag so you will only get the first
Try this instead
Hope this will work as it should.
/Dennis
Thanks Again,
It is not working ......
Regards,
sravani
Hi,
I came to post a little early before so I changed the code in relation to what you got by email. Do not know if it's the version you have tested.
I'll try to help the best I can:)
/Dennis
Hi Sravani,
I've now had the opportunity to test the xslt which I wrote to you earlier to day.
I've now had the opportunity to test the xslt which I wrote to you earlier in the day.
And with this code below I get displyed all childs of the currentpage, and the first li gets the class "selected".
So hope you will get it work with this code.
/Dennis
Thanks for your reply,
I guess my explaination is not clear
I have main menu Community ,Company......etc
and 2nd level navigation for Community ------ 1.customer 2. Support &
Comany---------- 1. About us,2.Management 3.contact us
when I am select the main menu tab means Community I need !st child ie. customer is selected and display content in customer page same for comapny -- I need About us page
Thanks a lot for u r replies...... :)
Okay. Unfortunately I misunderstood your question. I am very sorry.
Hope you find a solution to your problem.
/Dennis
So, if I'm reading this correctly, you don't want a page for Community.... but that's more the title for all of the nodes below in (Customer, Support etc...)...
If that's the case, what you can do is set up an umbraco redirect, so that when they click on Commuity, instead of going to the Community page, they get redirected to the document that you've selected it to go to.
To do this, you should add a content picker to each of your top level pages, and give it the property alias 'umbracoRedirect'. Then for each of your pages, select the first child in that redirect field. Umbraco should automatically redirect to that sub page.
http://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracoredirect
I know this isn't ideal, as it won't automatically pick up your first child item, but if you want to keep that site structure, and still have the functionality you're requesting, then I think it's the best way.
- Sean
Thanks for the Reply ,
I tried the content picker and link to the child page content but it is not redircte to that page.
It show me the same result.
Regards,
Sravani
Hmmm, weird.
I haven't used this myself, so this is kind of the blind leading the blind. Reading the documentation, umbracoRedirect is supposed to just be a temporary thing, not a permanent thing. Instead, you should try using this package:-
http://our.umbraco.org/projects/backoffice-extensions/permanent-redirect
Follow the instructions, and see if it works. Not sure why the other one didn't work though.
Thanks All,
Problem is solved with umbracoInternalRedirectId & content picker ..... :)
Regards,
Sravani
is working on a reply...