I am building a site for a client, the site hosts various seperate sports clubs and respective sports. So we have a content structure something like this:
Content - Main Holding Site -- Club 01 --- Club Sport 0101 -- Club 02 --- Club Sport 0201 --- Club Sport 0202
I am trying to edit the Runway Drow Down navigation XSLT to enable me to have a different parent depending on where you are so a Club and ClubSport could have different navigations. For the sake of explaining this I have created four document types:
Main Club ClubSport TextPage
There is only one Main, Clubs can only be directly under Main, ClubSports can only be directly under Clubs, TextPages can be in any on the other three and TextPages can be within TextPages.
I know that when $currentPage is @level=1 then we are at Main and so that is the parent.
My problem is that when we're at anything other than @level=1 I could be (say when @level=2) on either a TextPage or Club and I can't figure out how to tell. I'm trying to go through some "whens" to test for the three or so different scenarios:
and I know this must be straightforward but I just can't see it! Aaarggh!
There's a bit more to this but if I can get this bit then I can probably figure the rest out myself (he says confidently...). Anyone have any much appreciated thoughts?
I haven't seen the entire XSLT code that you'd like to change, but if you want to do something when you are on a level 2 node, and the current used document type is equal to Club, instead of this:
Ok, I have one last issue, that is that when, say, @level>=3, we might be on a text page under a Club or a ClubSport. So, it seems I need to be able to look up the hierarchy and see whether there is a ClubSport, Club or Main above me and choose the lowest level one to be the parent...
i.e. In this example, TextPage0101' parent would be Club 01 and TextPage010101's parent would be ClubSport0101.
Content - Main Holding Site -- Club 01 --- Club Sport 0101 ----TextPage010101 --- TextPage0101 -- Club 02 --- Club Sport 0201 --- Club Sport 0202
Thanks, but not quite, I'm not being clear. Say the TextPage you are on is on level 6, that TextPage may or may not have a ClubSport ancestor at level 3. If it does then level 3 will be the root of my navigation. If instead it has a Club ancestor at level 2 then that will be the root and lastly if neither of the first two apply then the root will be Main at level 1.
I haven't tried exactly what we want to achieve here, so it might not be the most beautiful solution. But first of all, we could make a variable containing some XML with all of the possible node id from the current page. This code should do it:
<xsl:variable name="nodes"> <data> <xsl:for-each select="$currentPage/ancestor-or-self::*[@isDoc and (name()= 'Main' or name()='Club' or name()='ClubSport') ] "> <id><xsl:value-of select="@id"/></id> </xsl:for-each> </data> </xsl:variable>
The above variable should now contain all of the nodes that has a document type of either 'Main', 'Club' or 'ClubSport'.
If we only want the node "closest" to the current page we can put this in another variable and use the GetXmlNodeById-extension like this:
Now you should have the XML of the node closest to the current page with a document type of either 'Main', 'Club' or 'ClubSport'.
To be sure that I haven't made any mistakes, you could try printing out both the $nodes and the $lastId inside two seperate <textarea>'s. Then we can be sure that we have got the right node's.
Kim, you're a genius, but I feel guilty as you've obviously put some work in here and the answer was simpler. In the first section you check for the nodes of particular doctypes like this...
<xsl:for-eachselect="$currentPage/ancestor-or-self::*[@isDoc and (name()= 'Main' or name()='Club' or name()='ClubSport') ] ">
Changing root of Runway Dropdown Nav
A little help please...
I am building a site for a client, the site hosts various seperate sports clubs and respective sports. So we have a content structure something like this:
Content
- Main Holding Site
-- Club 01
--- Club Sport 0101
-- Club 02
--- Club Sport 0201
--- Club Sport 0202
I am trying to edit the Runway Drow Down navigation XSLT to enable me to have a different parent depending on where you are so a Club and ClubSport could have different navigations. For the sake of explaining this I have created four document types:
Main
Club
ClubSport
TextPage
There is only one Main, Clubs can only be directly under Main, ClubSports can only be directly under Clubs, TextPages can be in any on the other three and TextPages can be within TextPages.
I know that when $currentPage is @level=1 then we are at Main and so that is the parent.
My problem is that when we're at anything other than @level=1 I could be (say when @level=2) on either a TextPage or Club and I can't figure out how to tell. I'm trying to go through some "whens" to test for the three or so different scenarios:
I think I need to be doing something like this:
and I know this must be straightforward but I just can't see it! Aaarggh!
There's a bit more to this but if I can get this bit then I can probably figure the rest out myself (he says confidently...). Anyone have any much appreciated thoughts?
Thanks,
Alex
Hi Alex
I haven't seen the entire XSLT code that you'd like to change, but if you want to do something when you are on a level 2 node, and the current used document type is equal to Club, instead of this:
I'm pretty sure you can do it like this:
/Kim A
Thanks so much Kim, that works a treat!
Ok, I have one last issue, that is that when, say, @level>=3, we might be on a text page under a Club or a ClubSport. So, it seems I need to be able to look up the hierarchy and see whether there is a ClubSport, Club or Main above me and choose the lowest level one to be the parent...
i.e. In this example, TextPage0101' parent would be Club 01 and TextPage010101's parent would be ClubSport0101.
Content
- Main Holding Site
-- Club 01
--- Club Sport 0101
----TextPage010101
--- TextPage0101
-- Club 02
--- Club Sport 0201
--- Club Sport 0202
I can't just say $parent/@level = $curentPage/@level - 1 as there could be multiple levels of TextPage...
If you want to know the level of the parent node, you can get it like this:
But if you want to do something when a parent node is on a specific level you should be able to do it like this:
Does that help you in what you where trying to do?
/Kim A
Hi Kim
Thanks, but not quite, I'm not being clear. Say the TextPage you are on is on level 6, that TextPage may or may not have a ClubSport ancestor at level 3. If it does then level 3 will be the root of my navigation. If instead it has a Club ancestor at level 2 then that will be the root and lastly if neither of the first two apply then the root will be Main at level 1.
Make sense?
Cheers,
Alex
Ahh okay. Well, let's try.
I haven't tried exactly what we want to achieve here, so it might not be the most beautiful solution. But first of all, we could make a variable containing some XML with all of the possible node id from the current page. This code should do it:
The above variable should now contain all of the nodes that has a document type of either 'Main', 'Club' or 'ClubSport'.
If we only want the node "closest" to the current page we can put this in another variable and use the GetXmlNodeById-extension like this:
Now you should have the XML of the node closest to the current page with a document type of either 'Main', 'Club' or 'ClubSport'.
To be sure that I haven't made any mistakes, you could try printing out both the $nodes and the $lastId inside two seperate <textarea>'s. Then we can be sure that we have got the right node's.
/Kim A
Kim, you're a genius, but I feel guilty as you've obviously put some work in here and the answer was simpler. In the first section you check for the nodes of particular doctypes like this...
So, what I've done is this
<xsl:when test="count($currentPage/ancestor-or-self::* [name()='ClubSport']) > 0">...
<xsl:when test="count($currentPage/ancestor-or-self::* [name()='Club']) > 0">...
<xsl:when test="count($currentPage/ancestor-or-self::* [name()='Main']) > 0">...
Which has worked a treat!
Thank you so much, Xslt is new to me and I'm struggling to get my head around the syntax but it's starting to sink in now!
Ahh okay, if that's what you wanted to achieve I'm glad it's working for you :)
Maybe I misunderstood the problem a bit, but great to hear that things worked out the way you wanted.
/Kim A
is working on a reply...