passing a node ID as a parameter to another template
Hi there.
I don't have much experience with XSLT, so I'm sure the answer to this will be something quite obvious that I've missed.
I have an XSLT macro that returns an image with a given ID.
I created a Document Type with 3 fields: an image picker that points to an image in a subfolder within my media folder, a url and a title. I want to recursively get the image for each object of that document type, wrap it in a link pointing to the object url, and put the title as the alt tag for the image.
As such, I wrote a second macro that is meant to generate the link markup and call the first macro for every object in my collection.
However, that doesn't seem to work. I am unsure whether I am passing the image ID incorrectly to the getImagebyID macro, or whether there's an error in my code.
I've set "breakpoints" via comments, and the main loop executes fine - it sets the urls in the href. The images refuse to appear, however, so I assume I'm either not passing the node ID correctly, or that the error is within the getLogoById function itself.
I assume that's meant to say apply-template, but what is the point of applying the same template twice? Also, how is the image returned, exactly? I see that in your include, the macro selects the required node, but should that not be within umbraco tags, to actually render the image?
And finally, for some reason, the main macro isn't saving at all(neither is the main macro, but I assume that was because of the fact that it was expecting an unexisting parameter on the media mode template). The error I'm getting is Error occured
Error in XSLT at line 11, char 10 9: <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> 10: 11: >>> <xsl:param name="currentPage" /> <<< 12: <xsl:variable name="homePage" select="$currentPage/ancestor-or-self::root/homepage" />
passing a node ID as a parameter to another template
Hi there.
I don't have much experience with XSLT, so I'm sure the answer to this will be something quite obvious that I've missed.
I have an XSLT macro that returns an image with a given ID.
I created a Document Type with 3 fields: an image picker that points to an image in a subfolder within my media folder, a url and a title. I want to recursively get the image for each object of that document type, wrap it in a link pointing to the object url, and put the title as the alt tag for the image.
As such, I wrote a second macro that is meant to generate the link markup and call the first macro for every object in my collection.
However, that doesn't seem to work. I am unsure whether I am passing the image ID incorrectly to the getImagebyID macro, or whether there's an error in my code.
I've set "breakpoints" via comments, and the main loop executes fine - it sets the urls in the href. The images refuse to appear, however, so I assume I'm either not passing the node ID correctly, or that the error is within the getLogoById function itself.
Thanks for the input.
That's the main template, and here's getLogoById
Hi Andrei,
You're mixing the XML formats in your include file - ($param/umbracoFile vs. data[@alias = 'umbracoFile']).
Try this, to see how templates can do a lot for you in XSLT:
Macro:
Include:
/Chriztian
Hi Chriztian,
Thanks for the reply.
I am a bit confused by a few things though:
I assume that's meant to say apply-template, but what is the point of applying the same template twice?
Also, how is the image returned, exactly? I see that in your include, the macro selects the required node, but should that not be within umbraco tags, to actually render the image?
And finally, for some reason, the main macro isn't saving at all(neither is the main macro, but I assume that was because of the fact that it was expecting an unexisting parameter on the media mode template). The error I'm getting is Error occured
Error in XSLT at line 11, char 10
9: <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
10:
11: >>> <xsl:param name="currentPage" /> <<<
12: <xsl:variable name="homePage" select="$currentPage/ancestor-or-self::root/homepage" />
Hi Andrei,
Oops - sorry! I've updated the code above (the <xsl:appl name... /> should just be deleted. As should the currentPage parameter from the include).
/Chriztian
That worked, AND cleared things up a bit at the same time.
Thank you for the help:)
Andrei
is working on a reply...