Copied to clipboard

Flag this post as spam?

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


  • Eric Warren 48 posts 68 karma points
    Aug 08, 2010 @ 15:23
    Eric Warren
    0

    XSLT/macro List Latest Blog post

    I am trying to list the latest blog post.  The code below works fine on umbraco 4 but dosn't work on 5.4.1.  The content structure is still the same.  Is there been a change on how umbraco reads XSLT.

     

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

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

    <xsl:param name="currentPage"/>

    <!-- Input the documenttype you want here -->
    <xsl:variable name="level" select="5"/>
      <xsl:variable name="noOfItems" select="3" />

    <xsl:template match="/">

    <!-- The fun starts here -->
    <br/>
    <ul class="events">


    <xsl:for-each select=" $currentPage/ancestor-or-self::root//node [@nodeTypeAlias ='Blog']/descendant::node[@level=5]/node[string(data[@alias='umbracoNaviHide']) != '1'] ">
     
    <xsl:if test="position()&lt;= $noOfItems">
    <span class="footerboxevents">
                                

      <li>
    <xsl:value-of select="umbraco.library:FormatDateTime(@createDate, 'dd.MM.yy')"/> <br/>
                    <a href="{umbraco.library:NiceUrl(@id)}">
                          <span style="font-size:14px;" class="footerboxevents">  <xsl:value-of select="@nodeName"/> </span>
                    </a>
    <hr/>
            </li>
    </span>

    </xsl:if>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

  • Kim Andersen 1447 posts 2197 karma points MVP
    Aug 08, 2010 @ 19:10
    Kim Andersen
    0

    Hi Eric.

    What happens if you try this for-each:

    <xsl:for-each select="
    $currentPage/ancestor-or-self::root//*[@isDoc][name()='Blog']/descendant::*
    [@isDoc]
    [@level=5]/*[@isDoc][string(umbracoNaviHide)!= '1'] ">

    /Kim A

  • Eric Warren 48 posts 68 karma points
    Aug 08, 2010 @ 19:57
    Eric Warren
    0

    Thanks that did the trick.  Is there a different way to write xslt for 4.5.1 vs. 4?  

  • Kim Andersen 1447 posts 2197 karma points MVP
    Aug 08, 2010 @ 21:31
    Kim Andersen
    0

    Glad it worked out for you Eric.

    In v4.5 and 4.5.1 the XML schema has changed so you need to write some different XSLT. You can see some examples here: http://our.umbraco.org/wiki/reference/xslt/45-xml-schema and here: http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema

    Actually, the new schema makes very good sense, so just go for it, and ask in here if anything doesn't go as you hoped for :)

    /Kim A

  • Eric Warren 48 posts 68 karma points
    Aug 17, 2010 @ 21:55
    Eric Warren
    0

    So I have ran into another problem with the blog.  If I nest the blog outside the website node the post comments function work fine, if I move the blog inside the website the post comment function does not work correctly. Any thought on how to get this to work. 

Please Sign in or register to post replies

Write your reply to:

Draft