I did test my values with the copy-of statement prior to posting, and as I mentioned above,
'If I skip testing, I get the desired output and the link works as expected...'
In other words, if I place a tick in the 'skip testing' checkbox, the macro saves and works in the published site.
I was wondering if there was a setting or something else that I needed to do to get the macro parsing/testing working with the umbraco library extensions.
I will take on board the checking for a value as that seems good practice.
Found this post on the old forum describing why XSLT sometimes throws an error while saving. Usually when I see the message I also press skip testing and test it in the site.
I have just read a comment from Dirk on another thread that says:
(Reason: the parameters passed in don't have a value until runtime, and
calling NiceUrl with a number that gets converted from an empty string
results in an OverflowException, which is probably the exception
message you've received in the 'red rectangle')
so I have a feeling that dawoe's solution will work. I'm presuming that as $position won't have a value at parse check time, it will mean that $selectedNode will be unassigned so I presume then that the parser will fail without the
umbraco.library - skip testing...
Is there any reason why I am not able to compile a macro that has {umbraco.library...} etc in it?
For example, the line
<a href="{umbraco.library:NiceUrl($selectedNode/@id)}" alt="{$selectedNode/@nodeName}">Read more...</a>will not compile. If I skip testing, I get the desired output and the link works as expected...
Whole macro:
<?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" exclude-result-prefixes="msxml umbraco.library"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:param name="currentPage"/> <xsl:param name="position" select="/macro/position"/> <xsl:template match="/"> <!-- start writing XSLT --> <xsl:variable name="selectedNode" select="$currentPage/node[position()=$position]"/> <a href="{umbraco.library:NiceUrl($selectedNode/@id)}" alt="{$selectedNode/@nodeName}">Read more...</a> </xsl:template> </xsl:stylesheet>Thanks for any ideas.
Sean
Sean,
The macro is failing as the position parameter is not set during testing. Thus, your selectedNode variable fails to get a proper node.
You can use default values in case the parameter is blank:
Case
Another option is to test the selectedNode for an id before using it in NiceUrl.
Hi Casey, thanks for the response.
I did test my values with the copy-of statement prior to posting, and as I mentioned above,
'If I skip testing, I get the desired output and the link works as expected...'
In other words, if I place a tick in the 'skip testing' checkbox, the macro saves and works in the published site.
I was wondering if there was a setting or something else that I needed to do to get the macro parsing/testing working with the umbraco library extensions.
I will take on board the checking for a value as that seems good practice.
Thanks again.
Hi Sean,
Found this post on the old forum describing why XSLT sometimes throws an error while saving. Usually when I see the message I also press skip testing and test it in the site.
Cheers,
Richard
This should solve it
umbraco.library:IsLoggedOn sometimes doing same problems, is there any check which helps with it?
Thanks all,
I have just read a comment from Dirk on another thread that says:
(Reason: the parameters passed in don't have a value until runtime, and calling NiceUrl with a number that gets converted from an empty string results in an OverflowException, which is probably the exception message you've received in the 'red rectangle')
so I have a feeling that dawoe's solution will work. I'm presuming that as $position won't have a value at parse check time, it will mean that $selectedNode will be unassigned so I presume then that the parser will fail without the
<xsl:if test="$selectedNode/@id != ''">
....
</xsl:if>
I'll have to test this at home tonight and mark the thread as solved if this works.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.