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.
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).
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.
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.
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?
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
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
Could you show us the code that you try to use, to render your content, please?
/Kim A
@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.
Ahh then I get it. Well, that is very strange. I haven't tried using the RenderMacroContent other that situations like this:
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
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.
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
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. :-)
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
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
is working on a reply...