Copied to clipboard

Flag this post as spam?

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


  • Alex Burr 77 posts 128 karma points
    May 21, 2010 @ 16:03
    Alex Burr
    0

    Parsing nodes NOT from currentPage

    Hi everyone,

    I'm still new to XSL so please have patience. What I am trying to do is set up my content like this:

    - Home
    - News
    -- News Item 1
    -- News Item 2
    -- News Item 3
    - Event List
    -- Event 1
    -- Event 2

    I am able to easily display the News Item nodes on the News page using the following transform:

    <xsl:template match="/">
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <xsl:sort select="data[@alias='createDate']" order="descending" />
    <h3 class="newsTitle"><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName" /></a></h3>
    <h4 class="newsDate">Posted <xsl:value-of select="umbraco.library:FormatDateTime(@createDate, 'MMMM d, yyyy')"/></h4>
    <p>
    <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(data [@alias = 'bodyText']), $MaxNoChars, '...')" />
    [<a href="{umbraco.library:NiceUrl(@id)}">Read more</a>]
    </p>
    </xsl:for-each>
    </xsl:template>

    And something similar for Events. However what I would also like to do is list the News Items and Events on the Home page. I am guessing my XSLT for the Home page will be very similar, except with a different select attribute on the xsl:for-each element. But I don't know what I should use!

    Any help is greatly appreciated. I apologize if this has been addressed already but I wasn't quite sure what to search on for this topic.

  • Jeff Grine 149 posts 189 karma points
    May 21, 2010 @ 16:22
    Jeff Grine
    0

    You might think about putting News and Event List under Home in your content tree, since you are pulling content from them into home. Either way you can use the nodeTypeAlias(document type alias) to identify the different elements. The way you have the structure now, the select would look like

    select="$currentPage/../node [@nodeTypeAlias='News']"

    Or if you move it

    select="$currentPage/node [nodeTypeAlias='News']"
  • Ralph van Vugt 57 posts 101 karma points
    May 21, 2010 @ 16:23
    Ralph van Vugt
    0

    Have a look at this topc: http://our.umbraco.org/forum/developers/xslt/6817-Get-level-2-pages-within-particular-parents

    If I'm not mistaken it is exactly what you're looking for. It sure helped me though.

  • Alex Burr 77 posts 128 karma points
    May 21, 2010 @ 17:00
    Alex Burr
    0

    Thanks guys,

    Jeff, thanks, I was wrong. News and Events are under Home in my content tree. It took me a while to realize I needed to include MY document type alias in there.

    This worked:

    <xsl:for-each select="$currentPage/descendant-or-self::node [@nodeTypeAlias='GJS_NewsItem']">

    Thanks to Ralph also... learned a lot about the @level property in that post!

Please Sign in or register to post replies

Write your reply to:

Draft