Copied to clipboard

Flag this post as spam?

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


  • Jonas Gunnarsson 44 posts 194 karma points
    Mar 24, 2010 @ 15:15
    Jonas Gunnarsson
    0

    My first xslt sub-nav

    Hi,

    I´m new to Umbraco, but so far I really like the system. But I have no experience with Xslt and now I try to make my first sub nav for my list document macro. My macro is called ListDocument, and I try to show the three latest post from that list.

    This is the Xslt-code:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
        <!ENTITY nbsp "&#x00A0;">
    ]>
    <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:variable name="noOfItems" select="3" />

        <xsl:template match="/">
       
            <ul class="events">
                <xsl:for-each select="$currentPage/ancestor-or-self::node//node [@nodeTypeAlias ='ListDocument']/node">
                    <xsl:sort select="@createDate" order="ascending"/>
        <li>
            <a href="{umbraco.library:NiceUrl(@id)}">                       
                <xsl:value-of select="@nodeName"/>               
            </a>       
        </li>
       
                </xsl:for-each>
            </ul>

        </xsl:template>

    </xsl:stylesheet>

    I'm running Umbraco v4 locally using Cassini web server.

    My problem is that nothings shows in my sub nav, and thats a problem ;-)

    Let me now if you need more information.

    thanks

    Jonas

  • Fergus Davidson 309 posts 588 karma points
    Mar 24, 2010 @ 15:19
    Fergus Davidson
    1

    have you tried the inbuilt 'list sub pages by document type' xslt?

    it sounds like it should do exactly what you are after

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 24, 2010 @ 15:22
    Jan Skovgaard
    0

    How does your content-structure look?

    Have you placed the XSLT macro in the right template perhaps?

    /Jan

  • Jonas Gunnarsson 44 posts 194 karma points
    Mar 24, 2010 @ 15:37
    Jonas Gunnarsson
    0

    Yes I think I have placed the xslt macro in the right template, I see the headline for my sub nav.

    I used the Runaway project to get a start and put the xslt macro on the start page, and my structure looks like this, :

    Runway Homepage
     -Installing runway modules
     -Go futher
     -Getting started
     -Faq
     -News (ListDocument)
       - News 1
       - News 2
       - News 3

     

  • Jonas Gunnarsson 44 posts 194 karma points
    Mar 24, 2010 @ 15:38
    Jonas Gunnarsson
    0

    bl_ndp_lot:

    Where do I find it?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 24, 2010 @ 16:15
    Jan Skovgaard
    1

    Hi Jonas

    You find it in the developer section, when you are creating a new XSLT macro you can select it from the dropdown of predefined XSLT snippets.

    When you are trying to see your navigation, which page are you trying to see it in? I think your current macro will only work when you are at the Runway homepage.

    /Jan

     

     

  • Fergus Davidson 309 posts 588 karma points
    Mar 24, 2010 @ 17:23
    Fergus Davidson
    0

    Jonas,

    as Jan said, when you create a new xslt, there is a dropdown which allows you to choose from a series of common xslt snippets.

    some of these require parameters passed to them , but i think that the one you need would be the 'list sub pages by document type', and this should work out of the box with no ammends. just select that snippet from the dropdown, save the resulting xslt, and away you go.

    if it is not quite right, those snippets are generally easy enough to follow and adjust to suit your needs.

    fergus

  • Jonas Gunnarsson 44 posts 194 karma points
    Mar 24, 2010 @ 19:06
    Jonas Gunnarsson
    0

    I don´t know what I did different, but when I tried my code on my other solution it worked! So problem solved.

    Thanks for helping me!

Please Sign in or register to post replies

Write your reply to:

Draft