Copied to clipboard

Flag this post as spam?

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


  • Maarten Boer 61 posts 82 karma points
    May 11, 2011 @ 12:38
    Maarten Boer
    0

    getting a value of the root page in all levels UMBRACO 4.7

    Hi,

    Got a bit of a struggle here. Im writing a Macro to get the value of a field from the rootpage. Depending on the current page this value can be shown or not.

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

    <xsl:param name="currentPage"/>
    <xsl:variable name="rootpage" select="$currentPage/ancestor-or-self::root" />


    <xsl:template match="/">

    <!-- The fun starts here -->
      
    <xsl:choose>

      <xsl:when test="local-name($currentPage)= 'Contactpage'">      
          <xsl:value-of select="$rootpage/data[@alias='newstext']"/>
      </xsl:when>
      <xsl:when test="local-name($currentPage)= 'Otherpages...'">
      </xsl:when> 
    <xsl:otherwise>
      <!-- Some code -->    
    </xsl:otherwise>
    </xsl:choose>
      


    </xsl:template>

    </xsl:stylesheet>

    For some reason it stay's empty.

    Maarten

  • skiltz 501 posts 701 karma points
    May 11, 2011 @ 12:41
    skiltz
    0
    <xsl:value-of select="$rootpage/newstext"/>
  • praveity 100 posts 125 karma points
    May 11, 2011 @ 13:00
    praveity
    0

    You are using old xslt schema that is used below umbraco v.4.7. 

    <xsl:value-of select="$rootpage/newstext"/> should work for it.

     

     

  • skiltz 501 posts 701 karma points
    May 11, 2011 @ 13:05
    skiltz
    0

    The new schema came in before 4.7  -  Maybe 4.5 from memory.

  • Maarten Boer 61 posts 82 karma points
    May 11, 2011 @ 13:23
    Maarten Boer
    0

    Mmm strange,

    I replaced my entry with <xsl:value-of select="$rootpage/newstext"/> but still empty.

    Just in case i added some random text too:

      <xsl:when test="local-name($currentPage)= 'Contactpage'">
        <xsl:value-of select="$rootpage/newstext"/>
        <p> Hello </p>
      </xsl:when>
     

     The value returns empty but the text 'Hello' is present in the source.

    Maarten

  • praveity 100 posts 125 karma points
    May 11, 2011 @ 13:29
    praveity
    0

    What does your newstext holds?

    What datatype is it?

    Cross check you have placed the content and published it.

  • Maarten Boer 61 posts 82 karma points
    May 11, 2011 @ 14:01
    Maarten Boer
    0

    newstext datatype is richtext and yes, the content on the homepage is publised.

    I've been experimenting a bit to be sure:

    The following does work but is not very nice since you need a 'hard' ID that refers to the rootpage

    <xsl:value-of select="umbraco.library:GetXmlNodeById('1068')/newstext" disable-output-escaping="yes"/>

     

  • Sean Holmesby 61 posts 82 karma points
    May 12, 2011 @ 03:12
    Sean Holmesby
    0

    I think the issue may be with $currentPage/ancestor-or-self::root

    If you're after your homepage, I don't think that will be your homepage, but instead, the item above your homepage.

    Maybe try $currentPage/ancestor-or-self::*[@isDoc and @level = 1]

    I could be wrong though.

Please Sign in or register to post replies

Write your reply to:

Draft