Umbraco Macro to update a logo dependant upon the page being viewed

umbraco LogoHeres a simple Macro for umbraco to allow you to update a logo or image on a page depending upon which page you have selected. You can use it to dynamically update images based upon content etc.

Here we check to see if the current page nodename is home (i.e. homepage) and set it to one thing, otherwise set it to something else. Obviously you can add as many conditions as you like.

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp “ ”> ]>
<xsl:stylesheet
version=”1.0″
xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”
xmlns:msxml=”urn:schemas-microsoft-com:xslt”
xmlns:umbraco.library=”urn:umbraco.library” xmlns:Exslt.ExsltCommon=”urn:Exslt.ExsltCommon” xmlns:Exslt.ExsltDatesAndTimes=”urn:Exslt.ExsltDatesAndTimes” xmlns:Exslt.ExsltMath=”urn:Exslt.ExsltMath” xmlns:Exslt.ExsltRegularExpressions=”urn:Exslt.ExsltRegularExpressions” xmlns:Exslt.ExsltStrings=”urn:Exslt.ExsltStrings” xmlns:Exslt.ExsltSets=”urn:Exslt.ExsltSets”
exclude-result-prefixes=”msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets “>

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

<xsl:param name=”currentPage”/>

<xsl:template match=”/”>

<xsl:choose>

<xsl:when test=”$currentPage/@nodeName = ‘HOME'”>
<div id=”logoDiv”>
<a href=”/”>
<img src=’/images/logo1.png’ alt=’This is logo 1′ class=’logomargin’ />
</a>
<!–<h1>Add some text here if you like</h1>–>
</div>
</xsl:when>

<xsl:otherwise>
<div id=”logoDiv”>
<a href=”/”>
<img src=’/images/logo2.png’ alt=’This is logo 2 for another page’ class=’logomargin’ />
</a>
<!–<h1>Add different text here also</h1>–>
</div>

</xsl:otherwise>
</xsl:choose>

</xsl:template>

</xsl:stylesheet>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.