Hello. I would like to show a list of pages below a node called Links, which is below the Home node. I would like the list to be generated automatically, so when someone adds a content page (or link), the page (link) will show up using XSLT (sort of like FAQ's). I would like to display the resulting list of links on another page. Can I use an existing xslt to customize it (for example, Sitemap), or do I need to dive deeper into XSLT?
try giving the predefined sitemap.xslt a go. I think the only thing you need to do is change the level variable so that you only get links from your desired level.
If you have several nodes on level 3 in your content tree, but only want to grab the nodes under the "Links"-node, there are some different ways you can solve your problem. Let's say that you are using the XSLT-template, Sitemap, like Jan said. Then you have to modify the parameter called parrent that looks like this out of the box:
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]"/>
The GetXMLNodeById method works well, thanks. I've been trying the last example you listed (for the Doc Type) and getting errors. SiteMap, I believe, uses the legacy schema. Is there a SiteMap version that uses the new xslt schema?
Hmm....sounds weird. The Sitemap version I created in my v4.5.2 was using the New XML schema. Could you try recreating the XSLT-file maybe? Does that help?
Also, the result returns links (niceURL) of lastname firstname (for eg, Anderson Kim). Is there a way for XSLT to insert a comma right after the last name?
Using the legacy schema, here's what works for your third example:
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::*[@level=1]//*[@level=3 and @nodeTypeAlias='DoctorLinks']"/>
It turns out the legacy version of your second example works best for me. Just a thought, but it seems it must be possible to grab the nodeName dynamically, without having to hardcode it into XSLT through either the ID, nodeName or nodeTypeAlias. I.e, the XSLT would know to use only the node in which it was inserted. That way I would need only one XSLT file, not a different one for every node.
Thanks for your help and time and making me dig deeper into XSLT.
Okay, so you are using the legacy schema now? Just aksing to be sure :)
What is the output of your xslt-file right now, and what would you like it to be? I'm not quite sure I understand what you want to achieve when you talk about dynamic nodeName, and comma after the lastname. Where does all those names come from?
Regarding my other question, only if you can spare a few minutes. When the current page shows the list of subpage links, it shows the name I've given to each page. In this case they are all doctor names, with each last name followed by a space and then first name (for sorting purposes). For eg, the first page would be named "Anderson Kim" (the alias would be anderson-kim). Is there a way in XSLT to parse the name, insert a comma at the first space and rejoin, so the link would read "Anderson, Kim"? I could simply add the comma when I name the page, but I don't want it to be included in the alias (for eg, I don't want to see "anderson,-kim.aspx".
single node sitemap
Hello. I would like to show a list of pages below a node called Links, which is below the Home node. I would like the list to be generated automatically, so when someone adds a content page (or link), the page (link) will show up using XSLT (sort of like FAQ's). I would like to display the resulting list of links on another page. Can I use an existing xslt to customize it (for example, Sitemap), or do I need to dive deeper into XSLT?
Thanks, Douglas
Hi Douglas
try giving the predefined sitemap.xslt a go. I think the only thing you need to do is change the level variable so that you only get links from your desired level.
/Jan
Thanks Jan, but I have several nodes at this level (level 3). Would there be any way I can isolate a node at this level?
Douglas
Hi Douglas
If you have several nodes on level 3 in your content tree, but only want to grab the nodes under the "Links"-node, there are some different ways you can solve your problem. Let's say that you are using the XSLT-template, Sitemap, like Jan said. Then you have to modify the parameter called parrent that looks like this out of the box:
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]"/>
Either grab the "Links"-node by id this way:
Or by the node name like this:
Or if the Links-node has it's own document type, you could probably do something like this:
If I have understod what you want to do, some of the above code should help you out :)
/Kim A
Thank you Kim, great suggestions. Just what I was looking for, didn't want to reinvent the wheel!
Glad to help!
As you say, there's no reason to reinvent the wheel every time a new challenge comes up, if the solution is just one small step ahead of you :)
Have a nice weekend.
/Kim A
Hi Kim,
The GetXMLNodeById method works well, thanks. I've been trying the last example you listed (for the Doc Type) and getting errors. SiteMap, I believe, uses the legacy schema. Is there a SiteMap version that uses the new xslt schema?
Thanks again,
Douglas
Hmm....sounds weird. The Sitemap version I created in my v4.5.2 was using the New XML schema. Could you try recreating the XSLT-file maybe? Does that help?
/Kim A
I modified your second example, just removing the IsDoc, and it works:
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::*[@level=1]//*[@level=3 and @nodeName='Podiatry']"/>
But I would prefer to use the DocType with the alias of DoctorLinks. But when I use the following, it errors out:
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@level=1]//DoctorLinks[@level=3]"/>
Also, the result returns links (niceURL) of lastname firstname (for eg, Anderson Kim). Is there a way for XSLT to insert a comma right after the last name?
Thanks again
Using the legacy schema, here's what works for your third example:
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::*[@level=1]//*[@level=3 and @nodeTypeAlias='DoctorLinks']"/>
It turns out the legacy version of your second example works best for me. Just a thought, but it seems it must be possible to grab the nodeName dynamically, without having to hardcode it into XSLT through either the ID, nodeName or nodeTypeAlias. I.e, the XSLT would know to use only the node in which it was inserted. That way I would need only one XSLT file, not a different one for every node.
Thanks for your help and time and making me dig deeper into XSLT.
Okay, so you are using the legacy schema now? Just aksing to be sure :)
What is the output of your xslt-file right now, and what would you like it to be? I'm not quite sure I understand what you want to achieve when you talk about dynamic nodeName, and comma after the lastname. Where does all those names come from?
/Kim A
Alas, what I needed was only to modify the original sitemap xslt from this:
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node [@level=1]"/>
to this:
<xsl:with-param name="parent" select="$currentPage"/>
Sorry for the confusion, maybe this will help another xslt novice
Ahh, okay so you just wanted to show the list from the current page that you are currently standing on. Well, great that you sorted it out Douglas!
/Kim A
Kim,
Regarding my other question, only if you can spare a few minutes. When the current page shows the list of subpage links, it shows the name I've given to each page. In this case they are all doctor names, with each last name followed by a space and then first name (for sorting purposes). For eg, the first page would be named "Anderson Kim" (the alias would be anderson-kim). Is there a way in XSLT to parse the name, insert a comma at the first space and rejoin, so the link would read "Anderson, Kim"? I could simply add the comma when I name the page, but I don't want it to be included in the alias (for eg, I don't want to see "anderson,-kim.aspx".
Thanks again, Doug
Yeah, you can do that.
Lets say, that you now output the nodeName like this:
This will give you the whole nodeName like it's written in the tree.
But if you want to insert a comma after the first word/name, you should be able to do it like this:
/Kim A
Wow, that's totally cool (as they say here in California). Thanks tons!!
is working on a reply...