Copied to clipboard

Flag this post as spam?

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


  • Matei Mihai 4 posts 24 karma points
    Jul 25, 2011 @ 23:26
    Matei Mihai
    0

    XSLT - Extracting property value from multiple pages

    Hi there,

    Please excuse my question if it's silly, I am a beginner to Umbraco, especially in the Macros and "XSLT" areas.

    Below is a screenshot of my content:

    Article 1, Article 2, etc. are content pages of document type "NewsArticle". The "NewsArticle" document type has a property called "newsArticleContent" of type Richtext Editor.

    On a section of my website, i inserted a macro i created that needs to display those articles, separated by the <br /> element. This is what my .XSLT code looks like at the moment:

    <xsl:variable name="newsArticleAlias" select="string('NewsArticle')"/>
        
    <xsl:template match="/">
      
      <xsl:for-each select="$currentPage/*/* [name() = $newsArticleAlias and string(umbracoNaviHide) != '1']">
        testing 123...
        <xsl:value-of select="data [@alias = 'newsArticleContent']" />
        <br />
      </xsl:for-each>

    </xsl:template>


    This is the content as it displays at the moment on the main webpage (The Cows Website). As you can see the content from the NewsArticle property isn't being displayed:

    Any help would be greatly appreciated.

    Thank you.

    Regards,
    Matei

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Jul 25, 2011 @ 23:43
    Chriztian Steinmeier
    0

    Hi Matei,

    Try something like this:

    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    
    <xsl:template match="/">
    
      <xsl:for-each select="$siteRoot/NewsArticle[not(umbracoNaviHide = 1)]">
        testing 123...
        <xsl:value-of select="newsArticleContent" />
        <br />
      </xsl:for-each>
    
    </xsl:template>

    - and maybe look for articles describing "The new XML Schema"...

    /Chriztian

  • Matei Mihai 4 posts 24 karma points
    Jul 26, 2011 @ 11:20
    Matei Mihai
    0

    Hi Chriztian,

    Thanks for your reply. Your example was good, I just had to add the NewsSection as well in front of the NewsArticle:

    <xsl:for-eachselect="$siteRoot/NewsSection/NewsArticle[not(umbracoNaviHide = 1)]">

    Regards,

    Matei

  • 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