Saving the XSLT within umbraco is not a problem, the editor doesn't flag any problems. The macro only now fails on the website, showing the following error:
Does the $landingPageProductLink contain a nodeId or a textstring with a URL in it?
If you are using a textstring to write in a URL in the landingPageProductLink-parametre, then you shall not use the NiceUrl-extension, but just do like this:
The macro "[landing-page-product]" has an alias "landingPageProductLink" of the type "contentPicker".
The user would have selected a node from the content tree to create the link. (All was working fine till upgrading to umbraco v 4.5.2, but now this macro no longer works).
The macro is XSLT but uses the "macro picker" plugin http://macropicker.codeplex.com/ to insert multiples of the same macro into the template.
Issue with umbraco.library:NiceUrl in umbraco v 4.5.2
Afternoon, I wonder if anyone can help me with a problem I've been trying to solve for months?
I upgraded to umbraco v 4.5.2 and ever since the following XSLT has failed to work correctly. I can no longer get the href="" value to appear.
If I remove the href attribute all together the rest of the Macro renders fine.
Please can anyone provide any insight as to what I've missed & how to fix it?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<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"/>
<xsl:param name="landingPageProductLink" select="/macro/landingPageProductLink"/>
<xsl:param name="landingPageProductThumbnail" select="/macro/landingPageProductThumbnail/node"/>
<xsl:param name="landingPageProductTitle" select="/macro/landingPageProductTitle"/>
<xsl:param name="landingPageProductText" select="/macro/landingPageProductText"/>
<xsl:template match="/">
<xsl:if test="$landingPageProductLink != ''">
<xsl:element name="a">
<xsl:attribute name="class">
<xsl:text>landing-page-product</xsl:text>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="umbraco.library:NiceUrl($landingPageProductLink)"/>
</xsl:attribute>
<xsl:element name="img">
<xsl:attribute name="width">
<xsl:text>102</xsl:text>
</xsl:attribute>
<xsl:attribute name="height">
<xsl:text>66</xsl:text>
</xsl:attribute>
<xsl:attribute name="src">
<xsl:value-of select="$landingPageProductThumbnail/data[@alias='umbracoFile']"/>
</xsl:attribute>
</xsl:element>
<xsl:element name="p">
<strong><xsl:value-of select="string($landingPageProductTitle)"/></strong>
<br/>
<xsl:value-of select="string($landingPageProductText)"/>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Regards,
Tom
Hi Thomas
How is it not working anymore? Do you have trouble saving the XSLT in the umbraco editor or does it just fail on the website?
/Jan
Hi Jan,
Saving the XSLT within umbraco is not a problem, the editor doesn't flag any problems. The macro only now fails on the website, showing the following error:
---
Error parsing XSLT file: \xslt\[landing-page-product].xslt Error parsing XSLT file: \xslt\[landing-page-product].xslt Error parsing XSLT file: \xslt\[landing-page-product].xslt Error parsing XSLT file: \xslt\[landing-page-product].xslt
---
Removing the following from the full macro above will enable the macro to render correctly, but obviously exclusing the href="" value.
<xsl:attribute name="href">
<xsl:value-of select="umbraco.library:NiceUrl($landingPageProductLink)"/>
</xsl:attribute>
Regards,
Tom
Hi Tom,
for the landingPageProductLink what's the marco parameter type?
Tom
Hi Thomas
Does the $landingPageProductLink contain a nodeId or a textstring with a URL in it?
If you are using a textstring to write in a URL in the landingPageProductLink-parametre, then you shall not use the NiceUrl-extension, but just do like this:
/Kim A
Hi,
Thanks for your responses,
"landingPageProductLink" has the parameter type of "contentPicker".
Regards,
Tom
Hi Kim A,
I tried the code you suggested:
---
---
That actually returned a link to the node in the content tree:
http://my.domain.com/umbraco/dialogs/treepicker.aspx?rnd=7a022944bc7a4252b5eaf29651f57a00&id=-1&treeType=content&contextMenu=true&isDialog=false&app=content
Any ideas please?
Regards,
Tom
Hi Thomas
Can you try printing out what the $landingPageProductLink contains like this:
In the top of your template. Just to make sure that the variable actually contains a nodeId.
/Kim A
Hi Kim A,
I Get the following written out on the page when using you're code.
(There are four instances on the page, each seems to have a unique identifier).
Thanks,
Tom
Hmm...that's pretty weird.
So the macro called landingPageProductLink is a contentPicker right? And you have choosen a node in the content tree when you inserted the macro?
Are you inserting the macro in a template, in a richtext editor or in a macro container?
/Kim A
hi Kim A,
The macro "[landing-page-product]" has an alias "landingPageProductLink" of the type "contentPicker".
The user would have selected a node from the content tree to create the link. (All was working fine till upgrading to umbraco v 4.5.2, but now this macro no longer works).
The macro is XSLT but uses the "macro picker" plugin http://macropicker.codeplex.com/ to insert multiples of the same macro into the template.
Regards,
Tom
Hey Thomas
Maybe you should try using the build-in Macro Container data type instead as the macropicker isn't compatible with v4.5+ yet as far as I know.
/Kim A
is working on a reply...