Hope someone is able to help - i am sure it will be an easy issue but i am pulling my hair out! I have a macro that ou can assign to a page that displays an image. It seems to work fine. HOWEVER - all subpages are showing the parent page image when i have not assigned an image to any of these subpages.
How are you passing the mediaId value from your template to your macro? I am guessing you're using Macro Parameter Syntax and that you're using [$propertyAlias] instead of [#propertyAlias]. The $ one uses a recursive value, meaning if the value isn't defined on the current node, it will take the value from the first parent that has it defined. So if you don't want this behavior, try using # instead.
Every day is a school day!! I never knew about this # tag and that has done the trick!! So using $ on a template as opposed to the # takes the value from the first parent that has it defined? I am assuming the $ signs in the macros are different?
You got it, see that wiki link for details -- yes, $ takes the value from the first parent that has it defined, just like the way the recursive option works on the umbraco:Item tag. And yes, $ inside the XSLT macro denotes a variable, something different :)
Newbie Image Issue
Hi Guys,
Hope someone is able to help - i am sure it will be an easy issue but i am pulling my hair out! I have a macro that ou can assign to a page that displays an image. It seems to work fine. HOWEVER - all subpages are showing the parent page image when i have not assigned an image to any of these subpages.
Code:<?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:variable name="mediaId" select="/macro/imageId"/>
<xsl:variable name="cropName" select="/macro/cropName"/>
<xsl:variable name="imageClass" select="/macro/imageClass"/>
<xsl:variable name="altTag" select="/macro/altTag"/>
<xsl:template match="/">
<xsl:if test="$mediaId > 0">
<xsl:variable name="media" select="umbraco.library:GetMedia($mediaId, 0)" />
<xsl:choose>
<xsl:when test="$altTag != ''">
<img src="{$media/umbracoFile}" class="{$imageClass}" alt="{$altTag}" />
<!--<img src="{$media/crops//crop [@name =$cropName]/@url}" class="{$imageClass}" alt="{$altTag}" />-->
</xsl:when>
<xsl:otherwise>
<img src="{$media/crops//crop [@name =$cropName]/@url}" class="{$imageClass}" alt="{$media/altTag}" />
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Any help would be much appreciated!!
Kenny
Hi Kenny,
How are you passing the mediaId value from your template to your macro? I am guessing you're using Macro Parameter Syntax and that you're using [$propertyAlias] instead of [#propertyAlias]. The $ one uses a recursive value, meaning if the value isn't defined on the current node, it will take the value from the first parent that has it defined. So if you don't want this behavior, try using # instead.
Hope this helps,
Tom
Tom,
Every day is a school day!! I never knew about this # tag and that has done the trick!! So using $ on a template as opposed to the # takes the value from the first parent that has it defined? I am assuming the $ signs in the macros are different?
You my friend are a legend!
Thanks a lot -
Kenny
You got it, see that wiki link for details -- yes, $ takes the value from the first parent that has it defined, just like the way the recursive option works on the umbraco:Item tag. And yes, $ inside the XSLT macro denotes a variable, something different :)
-Tom
is working on a reply...