Copied to clipboard

Flag this post as spam?

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


  • suzyb 474 posts 932 karma points
    Jun 20, 2011 @ 14:59
    suzyb
    0

    umbraco.library:RenderMacroContent pageid not working

    I am using umbraco.library:RenderMacroContent in a for loop to call an xslt macro that formats a certain value. However it doesn't seem to pass in the pageid value if it isn't set to $currentPage/@id.

    Here is my code (the macro FormatSalary takes several properties of the $currentPage and combines them)

    <xsl:for-each select="$data">
      <xsl:if test="position() &lt;= $numberOfItems">
          <xsl:value-of select="current()/@id" />
          <xsl:value-of select="umbraco.library:RenderMacroContent('&lt;?UMBRACO_MACRO macroAlias=&quot;FormatSalary&quot;&gt;&lt;/?UMBRACO_MACRO&gt;', current()/@id)" disable-output-escaping="yes"/>
      </xsl:if>
    </xsl:for-each>

    If I have $currentPage/@id in for the pageid parameter FormatSalary's $currentPage is set.  However with current()/@id or just @id it is not.

    I don't see what I've done wrong, could someone enlighten me.

  • Sebastian Dammark 583 posts 1407 karma points
    Jun 20, 2011 @ 16:39
    Sebastian Dammark
    0

    Are you trying to render an XSLT macro or a UserControl ?

    I believe that it's only XSLT macros that can be rendered through RenderMacroContent.

     

  • suzyb 474 posts 932 karma points
    Jun 20, 2011 @ 16:44
    suzyb
    0

    XSLT macro although it does use a custom library function.  I've included the code for the macro I call

    <?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:SearchConsultancy.Library="urn:SearchConsultancy.Library"
      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 SearchConsultancy.Library 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:if test="$currentPage/salaryFrom != ''"> 
        <xsl:value-of select="SearchConsultancy.Library:FormatSalary($currentPage/salaryFrom, false())"/>
    </xsl:if>
    <xsl:if test="$currentPage/salaryTo != ''">   
        - <xsl:value-of select="SearchConsultancy.Library:FormatSalary($currentPage/salaryTo, false())"/>
    </xsl:if>
    <xsl:if test="$currentPage/salaryPer != ''">
         Per <xsl:value-of select="$currentPage/salaryPer"/>
     </xsl:if>

    </xsl:template>

    </xsl:stylesheet>
  • Sebastian Dammark 583 posts 1407 karma points
    Jun 20, 2011 @ 16:47
    Sebastian Dammark
    0

    Well, it looks fine.

    Does the macro work if you don't render it through RenderMacroContent ?

  • suzyb 474 posts 932 karma points
    Jun 20, 2011 @ 16:48
    suzyb
    0

    Yes.  And it is calling the macro as putting a simple value-of in FormatSalary shows the output.

Please Sign in or register to post replies

Write your reply to:

Draft