Copied to clipboard

Flag this post as spam?

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


  • Jesper Pedersen 5 posts 25 karma points
    Nov 05, 2010 @ 19:00
    Jesper Pedersen
    0

    How to list news pages?

    Hello..

    I'm currently using this:

    <xsl:variable name="pressNodes" select="umbraco.library:GetXmlNodeById(1106)/node [string(data [@alias='umbracoNaviHide']) != '1']"/>


    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$pressNodes">
    <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>

    But i can't get it to work.

    What i want it to do is, to list alle the child-pages to News (id 1106) 

    Whats wrong with the code?

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 05, 2010 @ 19:14
    Jan Skovgaard
    0

    Hi Jesper

    try writing this in your file

    <textarea><xsl:copy-of select="$pressNodes" /></textarea>

    This makes it easy for you to see what XML is returned, if any. When you know what you get returned it's easier to figure out how to apply the xslt.

    Also...what version of Umbraco are you running? If it's 4.5.2 it makes sense that the code does not work, since the XML schema has changed. So unless you have actively changed the Schema to legacy you are running the new schema and then your code needs to be modified accordingly.

    /Jan

  • Jesper Pedersen 5 posts 25 karma points
    Nov 05, 2010 @ 20:36
    Jesper Pedersen
    0

    Hi Jan

    It is 4.5.2 i'm running?

    So all the code needs to be replaced?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 05, 2010 @ 20:41
    Jan Skovgaard
    0

    Hi Jesper

    Ok, then you're running the new schema. You can change it to run legacy by going to the config folder and open the umbracosettings.config where you can change the schema.

    But actually I'll recommend you to use the new schema.

    Try to create XSLT macro and choose one of the predefined templates and study the code in there.

    And then try to look at the XML output you get from the copy-of - then I think you'll soon figure out how to fetch the info.

    If you can't at all get your head around it, just let us know :)

    /Jan

  • Jesper Pedersen 5 posts 25 karma points
    Nov 05, 2010 @ 20:59
    Jesper Pedersen
    0

    Hmm.. When i select the List sub pages by date and limit I get this:

    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">

    And that lists all my pages. My strukture is as:

    Side 1
    Side 2
    Side 3
    News
     - News 1
     - News 2

    So I will need to read only the News sub pages.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 05, 2010 @ 21:12
    Jan Skovgaard
    0

    Hi

    I did'nt mean you should just rely on the out of box functionality. The principle you used in the posted code is the same. The syntax is different.

    Try this out

    <xsl:variable name="pressNodes" select="umbraco.library:GetXmlNodeById(1106)/* [@isDoc and string(umbracoNaviHide) != '1'"/>


    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$pressNodes">
    <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>

    Be aware that you'll also need a variable called "numberOfitems" - if you want to list all of the news then just remove the <xsl:if></xsl:if>

    Hope this helps

    /Jan

  • Jesper Pedersen 5 posts 25 karma points
    Nov 05, 2010 @ 22:24
    Jesper Pedersen
    0

    Well.. I have tried that, but i must have messed the code up, because it's working now :)

    Thanks!!

Please Sign in or register to post replies

Write your reply to:

Draft