<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>
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>
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
Provided that your homepage has the doctype 'Frontpage', you could do this:
is working on a reply...