Copied to clipboard

Flag this post as spam?

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


  • Laura Holland 82 posts 103 karma points
    Oct 31, 2009 @ 02:26
    Laura Holland
    0

    Xslt template listing descendant nodes by date?

    Hi, complete xslt newcomer here.

    I tried to use the built in xslt template/macro for displaying the most recent pages in the node, but nothing is showing up. I added the macro with the numberOfItems parameter, but nothing doing. The code (straight from the umbraco built in template, I have changed nothing):

    <?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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:uForum="urn:uForum" xmlns:uForum.raw="urn:uForum.raw"
        exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets uForum uForum.raw ">

    <xsl:output method="xml" omit-xml-declaration="yes" />

    <xsl:param name="currentPage"/>

    <!-- Don't change this but create a 'number' element in your -->
    <!-- macro with the alias of 'numberOfItems' -->
    <xsl:variable name="numberOfItems" select="/macro/numberOfItems"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <xsl:sort select="@updateDate" order="descending"/>
        <xsl:if test="position() &lt;= $numberOfItems">
            <li>
                <a href="{umbraco.library:NiceUrl(@id)}">
                    <xsl:value-of select="@nodeName"/>
                </a>
            </li>
        </xsl:if>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

    When I dropped the macro onto the page, I specified the number "3", which I assume means it should display the 3 most recent pages in the node? Maybe it's getting messed up because the child pages are all a different document type than the page where the macro is? Sorry, I really can't get the hang of xslt, I don't know what my block is about it..

  • Masood Afzal 176 posts 522 karma points
    Oct 31, 2009 @ 02:30
    Masood Afzal
    0

    Have you checked child pages have 'umbracoNaviHide' property set to false?

  • Masood Afzal 176 posts 522 karma points
    Oct 31, 2009 @ 02:34
    Masood Afzal
    0

    Also make it sure that you have created a parameter ''numberOfItems' (integer type) in macro definition (developer section).

     

  • Laura Holland 82 posts 103 karma points
    Oct 31, 2009 @ 02:35
    Laura Holland
    0

    Where would I check this? The pages are published, but have role-based permissions (the entire node and child has the same permission)..

  • Masood Afzal 176 posts 522 karma points
    Oct 31, 2009 @ 02:37
    Masood Afzal
    0

    Have you created parameter 'numberOfItems in macro (umbraco developer section)?

  • Laura Holland 82 posts 103 karma points
    Oct 31, 2009 @ 02:40
    Laura Holland
    0

    I did create the numberOfItems parameter in the macro..

  • Masood Afzal 176 posts 522 karma points
    Oct 31, 2009 @ 02:46
    Masood Afzal
    0

    Does it work without macro parameter? xslt looks ok

  • Laura Holland 82 posts 103 karma points
    Oct 31, 2009 @ 02:50
    Laura Holland
    0

    I removed the macro parameter but it still doesn't work. The output is an empty <ul>

  • Laura Holland 82 posts 103 karma points
    Oct 31, 2009 @ 02:54
    Laura Holland
    0

    Thanks Masood, You figured it out. It was the parameter, like you thought. I removed it from the macro and the xslt file and now it works.

  • Masood Afzal 176 posts 522 karma points
    Oct 31, 2009 @ 02:58
    Masood Afzal
    0

    Hi Laura,

    I have tested your macro and it works fine. Not sure what is the issue, may be permissions?

  • Laura Holland 82 posts 103 karma points
    Oct 31, 2009 @ 03:11
    Laura Holland
    0

    I don't know what was wrong but it definitely was something to do with the parameter. Once I removed it, it worked like a charm. Thanks again for your help.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies