Copied to clipboard

Flag this post as spam?

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


  • Ron Brouwer 273 posts 768 karma points
    Feb 12, 2010 @ 11:39
    Ron Brouwer
    0

    umbraco.library.RenderMacroContent ignores PageId

    Hi,

    It seems that umbraco.library.RenderMacroContent ignores the parameter PageId, whatever I put into PageId the $currentPage in my xslt is always the actual currentPage and not the node with the PageId.

    Any suggestions?

    Ron

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 12, 2010 @ 13:51
    Kim Andersen
    0

    Could you show us the code that you try to use, to render your content, please?

    /Kim A

  • Ron Brouwer 273 posts 768 karma points
    Feb 12, 2010 @ 15:47
    Ron Brouwer
    0

    @Kim

    The code itself is not that interesting:

     umbraco.library.RenderMacroContent("text containing macro",$product/@id);

    The only problem is that umbraco ignores $product/@id and uses the currentPage instead.

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 13, 2010 @ 18:41
    Kim Andersen
    0

    Ahh then I get it. Well, that is very strange. I haven't tried using the RenderMacroContent other that situations like this:

    <xsl:variable name="content" select="$currentPage/data[@alias='content']"/>
    <xsl:value-of select="umbraco.library:RenderMacroContent($content, $currentPage/@id)" disable-output-escaping="yes"/>

    So I have only tried it with content from the current page. And of course you are sure that the $product isn't the same as the current page(I'm sure you have total control over this, but just to make sure).

    Otherwise I'm sorry, but I can't help then.

    /Kim A

  • Stephan Lonntorp 195 posts 212 karma points
    Feb 13, 2010 @ 19:28
    Stephan Lonntorp
    0

    if you look in the source of RenderMacroContent, it actually loads the page with the provided ID, however, it's the text value that you supply it with that is rendered, not the property of the page you pass by id.

    So, in order for your xslt to work, you need to get the property from the $product, that contains the macro you want to render. The ID parameter really has no effect on the passed macro text.

  • Ron Brouwer 273 posts 768 karma points
    Feb 14, 2010 @ 10:56
    Ron Brouwer
    1

    Thanks,

    Well the macro (xslt) needs to render in the contact of the passed pageid. Otherwise the parameter has no use.
    When the xsltprocessor sets the currentPage param it should be the same node as the id passed to RenderMacro, and it is not.

    I solved it for myself by passing an extra param "productId" to my macro and the use of GetXmlNodeById, but stil, it should work fine without that.

    Ron

  • Heather Floyd 604 posts 1002 karma points MVP 5x c-trib
    Mar 09, 2010 @ 21:50
    Heather Floyd
    0

    I have a somewhat related issue -

    I have a node with several sub-nodes which are essentially "sections" of the main node. Each "section" includes a RTE property (bodyText), a section header, and a multi-line text field (CodeBlock). I would like to be able to insert a simple macro (called "InsertCode") into my RTE which basically just renders the content of the "CodeBlock" property. (The purpose is in order to insert special html from shoppingcart/autoresponder services, etc that won't go through the "Tidy" wringer and get messed up)

    I then have an XSLT which "builds" the page - rendering each of these "sections" into one page (using <xsl:for-each select="$currentPage/node [string(./data [@alias='umbracoNaviHide']) != '1']"> ). Generally this works, but the issue is that my "InsertCode" macro, if included in one of the section's bodyText is never rendered properly.

    Like Ron, I had assumed that the ID passed in through a "RenderMacroContent" call would determine the "$currentPage" param used for the internal macro. This seems logical, after all... since the macro is supposed to be acting on the "current node" that includes the macro. If it always determines that the "currentPage" is the actual physical node the xslt is running in, why do we need to specify it at all?

    Anyway, creative solutions appeciated. :-)

  • Heather Floyd 604 posts 1002 karma points MVP 5x c-trib
    Mar 09, 2010 @ 22:27
    Heather Floyd
    0

    Okay,

    My own solution (similar to Ron's) but since I use the InsertCode macro in other places ont he site where it works fine assuming currentPage, I made the PageNode param optional (if blank, using currentpage) and then I have my page compiling xslt do a little replace, to add the proper ID in case it has been excluded in the Macro

    <xsl:variable name="BodyTextReplaced">
                <xsl:value-of select="umbraco.library:Replace(data [@alias = 'bodyText'], 'pagenode=&quot;&quot;', concat('pagenode=&quot;',@id,'&quot;'))"/>
            </xsl:variable>
            <xsl:variable name="BodyTextRendered" select="umbraco.library:RenderMacroContent($BodyTextReplaced, @id)"/>

    And... it works!

    Though any other macros I want to use in this fashion, I will have to make the same modification to... Not ideal, but it functions.

    ~Heather

Please Sign in or register to post replies

Write your reply to:

Draft