Copied to clipboard

Flag this post as spam?

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


  • Dan 1288 posts 3921 karma points c-trib
    Jan 07, 2010 @ 19:03
    Dan
    0

    Simple variable passed into macro won't output value

    Hi,

    I'm trying to get a variable from a macro into XSLT and output in XHTML.  The variable is 'itemsPerLine'. The macro is:

    <umbraco:Macro Alias="Thumbnails" itemsPerLine="12" runat="server"></umbraco:Macro>

    The xslt is:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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"/>
    <!-- Input the repeatable custom contents property alias here -->
    <xsl:variable name="propertyAlias" select="string('column2')"/>
    <xsl:template match="/">
    <xsl:variable name="itemsPerLine" select="/macro/itemsPerLine"/>
    <xsl:if test="$currentPage/data [@alias = $propertyAlias]/items/item">
    <xsl:for-each select="$currentPage/data [@alias = $propertyAlias]/items/item">
    <div class="people margin height">
    <xsl:if test="string(current()/data[@alias='thumbnailImage1']) != ''">
    <xsl:element name="img">
    <xsl:attribute name="src">
    <xsl:value-of select="umbraco.library:GetMedia(current()/data[@alias='thumbnailImage1'], 'false')/data[@alias='umbracoFile']" />
    </xsl:attribute>
    <xsl:attribute name="alt">
    <xsl:value-of select="./data [@alias = 'thumbnailName']" disable-output-escaping="yes"/>
    </xsl:attribute>
    </xsl:element>
    </xsl:if>
    <div>
    <xsl:if test="string(current()/data[@alias='thumbnailImage2']) != ''">
    <xsl:element name="img">
    <xsl:attribute name="src">
    <xsl:value-of select="umbraco.library:GetMedia(current()/data[@alias='thumbnailImage2'], 'false')/data[@alias='umbracoFile']" />
    </xsl:attribute>
    <xsl:attribute name="alt">
    <xsl:value-of select="./data [@alias = 'thumbnailName']" disable-output-escaping="yes"/>
    </xsl:attribute>
    </xsl:element>
    </xsl:if>
    <h2>
    <xsl:value-of select="./data [@alias = 'thumbnailName']" disable-output-escaping="yes"/><xsl:value-of select="$itemsPerLine"/>
    </h2>
    <p><xsl:value-of select="./data [@alias = 'thumbnailText']" disable-output-escaping="yes"/></p>
    </div>
    </div>
    </xsl:for-each>
    <!-- Live Editing support for related links. -->
    <xsl:value-of select="umbraco.library:Item($currentPage/@id,$propertyAlias,'')" />
    </xsl:if>
    </xsl:template>
    </xsl:stylesheet>

    Can anyone see why this value doesn't output?

    Thanks all.

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jan 07, 2010 @ 19:23
    Douglas Robar
    0

    All look perfect. But... in the Macro itself (Developer section, Macro section of the treeview), have you added the itemsPerLine parameter? If not, your macro call can't pass values into the xslt. The Macro is the gateway (or 'api' if you will) between your umbraco:Macro call and the xslt or .net control that will process it.

    Let us know what you find out.

    cheers,
    doug.

  • Dan 1288 posts 3921 karma points c-trib
    Jan 07, 2010 @ 21:07
    Dan
    0

    You've opened up a world of new possibilities Doug!  Thanks very much, that's working now :)

Please Sign in or register to post replies

Write your reply to:

Draft