Copied to clipboard

Flag this post as spam?

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


  • Steve 472 posts 1216 karma points
    Oct 12, 2012 @ 21:49
    Steve
    0

    Referencing A Property of a Doctype

    How would I refrence the property "featuredImage" of a DocType named "NewsArticle" using xslt?

    I believe it would be something like this:

    <xsl:variable name="featuredNewsImges" select="$currentPage/ancestor::NewsArticle[@featureedImage]"/>

    I am trying to select these "featuredImage" 's and put them in a slideshow.

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Oct 12, 2012 @ 22:55
    Chriztian Steinmeier
    0

    Hi Steve,

    Properties get their own element in the XML - e.g.:

    <NewsArticle isDoc="" id="1200" nodeName="My News Story">
       <featuredImage></featuredImage>
    </NewsArticle>

    (Shorten a lot - but the general idea should be clear)

    So when you've successfully located the NewsArticle you just add /featuredImage to get that - @ is used for the attributes (e.g. @isDoc, @id etc.)

    That's one thing - the other thing is that you're only searching along the ancestor axis of the current page, which might not be enough - you might want to locate a common ancestor first, and then go down that one to select the NewsArticles - something like this:

    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    <xsl:variable name="newsRoot" select="$siteRoot/NewsArticles" />
    <xsl:variable name="featuredImages" select="$newsRoot//NewsArticle/featuredImage" />
    

    /Chriztian

  • Steve 472 posts 1216 karma points
    Oct 15, 2012 @ 14:18
    Steve
    0

    Chriztian,
    Thanks! but I am still very new to Umbraco and xslt/xpath. How would the xsl tag look to refrence the "NewsArticle" if the folder is located at "Content/Home Page/News/Alumni/2012" under the Umbraco content section? I would greatly appreaciate this help as it would help me better understand xslt.

  • 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