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>

New Website Launched

Today I released a new version of the Simon Antony freelance developer website – it now covers all the areas I specialise within and hopefully gives my clients a new portal to visit. Over the coming months, more content will be added, including the ability for recruiters and clients to have their own login area and download files specific to them i.e. documentation, CV etc

http://www.simonantony.net is the place to go.

Simon