Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Douglas 10 posts 30 karma points
    Oct 22, 2010 @ 07:39
    Douglas
    0

    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

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Oct 22, 2010 @ 08:11
    Jan Skovgaard
    0

    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

  • Douglas 10 posts 30 karma points
    Oct 22, 2010 @ 17:18
    Douglas
    0

    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

  • Kim Andersen 1447 posts 2196 karma points MVP
    Oct 22, 2010 @ 23:38
    Kim Andersen
    0

    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:

    <xsl:with-param name="parent" select="umbraco.library:GetXmlNodeById('yourIdHere')"/>

    Or by the node name like this:

    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]//*[@isDoc and @level=3 and @nodeName='Links']"/>

    Or if the Links-node has it's own document type, you could probably do something like this:

    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]//LinksDocumentTypeHere[@isDoc and @level=3]"/>

    If I have understod what you want to do, some of the above code should help you out :)

    /Kim A

     

  • Douglas 10 posts 30 karma points
    Oct 23, 2010 @ 00:05
    Douglas
    0

    Thank you Kim, great suggestions.  Just what I was looking for, didn't want to reinvent the wheel!

  • Kim Andersen 1447 posts 2196 karma points MVP
    Oct 23, 2010 @ 18:34
    Kim Andersen
    0

    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

  • Douglas 10 posts 30 karma points
    Oct 26, 2010 @ 06:00
    Douglas
    0

    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

  • Kim Andersen 1447 posts 2196 karma points MVP
    Oct 26, 2010 @ 08:49
    Kim Andersen
    0

    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

  • Douglas 10 posts 30 karma points
    Oct 26, 2010 @ 23:08
    Douglas
    0

    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

  • Douglas 10 posts 30 karma points
    Oct 27, 2010 @ 07:27
    Douglas
    0

    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.

  • Kim Andersen 1447 posts 2196 karma points MVP
    Oct 27, 2010 @ 09:10
    Kim Andersen
    0

    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

  • Douglas 10 posts 30 karma points
    Oct 27, 2010 @ 09:18
    Douglas
    0

    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

  • Kim Andersen 1447 posts 2196 karma points MVP
    Oct 27, 2010 @ 18:04
    Kim Andersen
    0

    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

  • Douglas 10 posts 30 karma points
    Oct 28, 2010 @ 00:56
    Douglas
    0

    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

  • Kim Andersen 1447 posts 2196 karma points MVP
    Oct 28, 2010 @ 08:48
    Kim Andersen
    0

    Yeah, you can do that.

    Lets say, that you now output the nodeName like this:

    <xsl:value-of select="@nodeName" />

    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:

    <xsl:value-of select="substring-before(@nodeName,' ')"/>
    <xsl:text>, </xsl:text>
    <xsl:value-of select="substring-after(@nodeName,' ')"/>

    /Kim A

  • Douglas 10 posts 30 karma points
    Oct 30, 2010 @ 02:15
    Douglas
    0

    Wow, that's totally cool (as they say here in California).  Thanks tons!!

Please Sign in or register to post replies

Write your reply to:

Draft