Copied to clipboard

Flag this post as spam?

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


  • Inmedia 124 posts 176 karma points
    Jun 15, 2012 @ 08:44
    Inmedia
    0

    Get property from frontpage... how?

    I need to get a value from a property from my frontpage, can anyone help me out - how can I do that?

    My XSLT looks like this, and it is the alias "defaultBannerImage" from the "otherwise" part, that  I need to get from the frontpage:

     

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <xsl:choose>


            <xsl:when test="string(bannerImage) != '0'">
              <div class="container banner" style="background-image: url({$currentPage/bannerImage})">
                 <div class="pagename">   
                   <h1><xsl:value-of select="$currentPage/overskrift" disable-output-escaping="yes"/></h1>
                 </div>
              </div>
            </xsl:when>


            <xsl:otherwise>
              <div class="container banner" style="background-image: url({/root/defaultBannerImage})">
                 <div class="pagename">   
                   <h1><xsl:value-of select="$currentPage/overskrift" disable-output-escaping="yes"/></h1>
                 </div>
              </div>
            </xsl:otherwise>
          </xsl:choose>
     
    </xsl:template>

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jun 15, 2012 @ 10:41
    Alex Skrypnyk
    0

    Hi Inmedia

    You could use something like that for selecting home node:

      <xsl:variable name="frontPage" select="$currentPage/ancestor-or-self::*[parent::root]" />

    or 

    <xsl:variable name="frontPage" select="$currentPage/ancestor-or-self::*[@isDoc and @nodeType = '1049']" />

    where 1049 - is nodeType of homeNode

  • Dan Okkels Brendstrup 101 posts 197 karma points
    Jun 17, 2012 @ 15:44
    Dan Okkels Brendstrup
    0

    Provided that your homepage has the doctype 'Frontpage', you could do this:

    <xsl:template match="/">
      <xsl:apply-templates select="$currentPage" mode="banner"/>
    </xsl:template>

    <xsl:template match="*" mode="banner">
      <div class="container banner" style="background-image: url({bannerImage})">
        <!--If no banner image is selected on the current page, pull the value from the homepage node-->
        <xsl:if test="not(normalize-space(bannerImage))">
          <xsl:attribute name="style">background-image: url(<xsl:value-of select="ancestor-or-self::Frontpage/bannerImage"/>)</xsl:attribute>
        </xsl:if>
        <div class="pagename">
           <h1><xsl:value-of select="overskrift" disable-output-escaping="yes"/></h1>
         </div>
      </div>
    </xsl:template>
Please Sign in or register to post replies

Write your reply to:

Draft