Load macro parameter from RichTextEditor (GetMedia)
Hi! I'm boxing with some xslt-code but I don't get it knocked out. I want to load an image folder from the mediapicker into a macro in te RTE, so the end-user can pick the folder that he/she wants. On the front the images will be load from the folder into the page/node. The following things have I done.
Ok, seems something is going wrong when trying to output the result of the slider in your rte. Really hard to tell what is wrong? Can you add the macro onto a template (most probably the template that is associated with the doc that has the rte on it) and browse the page, appending ?umbdebugshowtrace=true... this will give some more info about the runtime error.
OK, in the trace information I get the following error:
umbracoMacro InnerExceptionValue was either too large or too small for an Int32. Value was either too large or too small for an Int32. at System.Convert.ToInt32(Double value) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType) at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args) at System.Xml.Xsl.CompiledQuery.Query.<xsl:template match="/">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug} current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList`1 {urn:schemas-microsoft-com:xslt-debug}namespaces) in \\www\xslt\Horizontalslider.xslt:line 23 at System.Xml.Xsl.CompiledQuery.Query.<xsl:apply-templates>(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator , Double , Double ) at System.Xml.Xsl.CompiledQuery.Query.Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.CompiledQuery.Query.Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) at umbraco.macro.GetXsltTransformResult(XmlDocument macroXML, XslCompiledTransform xslt, Dictionary`2 parameters) at umbraco.macro.loadMacroXSLT(macro macro, MacroModel model, Hashtable pageElements)
i'm suspecting it's the GetMedia() call which is erroning in this case, so double check whether the parameter being passed $source does have a value. Also not sure if
<xsl:if test="($source)">
is a good test, it might always return true because of the extra parenthesis...
Ouch, no good, and you're sure about the macro parameter aliases (seems fine from what i see, but always good to doublecheck anyway...); If you repro this issue on another install, make sure to log this on Codeplex (if it hasn't been already) and mention umbraco version and repro steps.
Haha, I've tried it without knowing that you've made that suggest. But that doesn't work. I tried to get info out of the parameter and it returned the id with the following request:
<xsl:value-of select="$source/*/@id"/>
And it returned the id, so I tried to insert it in the variable like this:
Load macro parameter from RichTextEditor (GetMedia)
Hi! I'm boxing with some xslt-code but I don't get it knocked out. I want to load an image folder from the mediapicker into a macro in te RTE, so the end-user can pick the folder that he/she wants. On the front the images will be load from the folder into the page/node. The following things have I done.
- XSLT:
- Create parameter "source" in the macro
- In the RichTextEditor select the macro, select an imagefolder from media with the mediapicker and save/publish
But I don't get anything back. Please help, to knock this out, before it does the same to me.
First thing to check: Does the source have a value?
If it doesn't, there's something wrong passing your id to the macro. If it does, try outputting what you get from GetMedia() using
Cheers,
/Dirk
In the editor the source have the following value:
<div umb_macroalias="Horizontalslider" umb_source="1179" ismacro="true"
onresizestart="return false;" umbversionid="9c7c5b2c-401f-4422-a470-f89425856976"
umbpageid="1417" title="This is rendered content from macro" class="umbMacroHolder">
<!-- startUmbMacro -->Error parsing XSLT file: \xslt\Horizontalslider.xslt<!-- endUmbMacro -->
</div>
It gives an error while parsing the XSLT file
Ok, seems something is going wrong when trying to output the result of the slider in your rte. Really hard to tell what is wrong? Can you add the macro onto a template (most probably the template that is associated with the doc that has the rte on it) and browse the page, appending ?umbdebugshowtrace=true... this will give some more info about the runtime error.
Cheers,
/Dirk
OK, in the trace information I get the following error:
umbracoMacro InnerExceptionValue was either too large or too small for an Int32.
Value was either too large or too small for an Int32.
at System.Convert.ToInt32(Double value)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
at System.Xml.Xsl.CompiledQuery.Query.<xsl:template match="/">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}
current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList`1 {urn:schemas-microsoft-com:xslt-debug}namespaces)
in \\www\xslt\Horizontalslider.xslt:line 23
at System.Xml.Xsl.CompiledQuery.Query.<xsl:apply-templates>(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator , Double , Double )
at System.Xml.Xsl.CompiledQuery.Query.Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.CompiledQuery.Query.Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
at umbraco.macro.GetXsltTransformResult(XmlDocument macroXML, XslCompiledTransform xslt, Dictionary`2 parameters)
at umbraco.macro.loadMacroXSLT(macro macro, MacroModel model, Hashtable pageElements)
i'm suspecting it's the GetMedia() call which is erroning in this case, so double check whether the parameter being passed $source does have a value. Also not sure if
is a good test, it might always return true because of the extra parenthesis...
Can you replace the above with following:
and see if you still get the error.
Cheers,
/Dirk
When I fill in the id of the mediafolder I get the images how it should be. So it seems to be that the id is not passed through the RTE properly.
There's is no error with your latest suggestion, so that worked out very well, but there is no image displaying.
Ouch, no good, and you're sure about the macro parameter aliases (seems fine from what i see, but always good to doublecheck anyway...); If you repro this issue on another install, make sure to log this on Codeplex (if it hasn't been already) and mention umbraco version and repro steps.
Cheers,
/Dirk
I'm now testing it in a template like this:
With no result...
Also worth trying to rename your parameter, altho i don't think it'll change much in this case...
Cheers,
/Dirk
Haha, I've tried it without knowing that you've made that suggest. But that doesn't work. I tried to get info out of the parameter and it returned the id with the following request:
And it returned the id, so I tried to insert it in the variable like this:
But it doesn't work.
Yes, it worked out! The variable to get data from the macro must be a param. (codeblindness all the way). Like this:
Should be:
<xsl:param name="source" select="/macro/source/Folder/@id" />
Thank you very much for helping me out Dirk. (we hadden het ook in het nederlands kunnen bespreken, maar daar help je niemand mee ;-) )
OMG, i didn't even see that... great find! Happy programming!
is working on a reply...