Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Niels 63 posts 119 karma points
    Oct 18, 2011 @ 09:27
    Niels
    0

    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:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
      <!ENTITY nbsp "&#x00A0;">
    ]>
    <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:variable name="source" select="/macro/source"/>
      
      <xsl:template match="/">
        
        <ul id="mycarousel" class="jcarousel-skin-tango">
        
          <xsl:if test="($source)">
          <xsl:variable name="images" select="$source"/>
          <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($images, true())"/>
            
          <xsl:for-each select="$mediaItems/Image">
            <xsl:variable name="picFile" select="umbracoFile"/>
            <li>

              <!-- this can be used to link to the image -->

              <xsl:element name="a">
                <xsl:attribute name="href">
                  <xsl:value-of select="./umbracoFile" />
                </xsl:attribute>

                <xsl:attribute name="id">
                  <xsl:text>gallery</xsl:text>
                </xsl:attribute>

                <xsl:attribute name="rel">
                  <xsl:text>shadowbox</xsl:text>
                  <xsl:text>[</xsl:text>
                  <xsl:value-of select="$currentPage/@nodeName"/>
                  <xsl:text>]</xsl:text>
                </xsl:attribute>
                
                <xsl:attribute name="title">
                  <xsl:value-of select="@nodeName"/>
                </xsl:attribute>

                <img>
                  <xsl:attribute name="src">
                    <xsl:text>/ImageGen.ashx?image=</xsl:text>
                    <xsl:value-of select="$picFile"/>
                    <xsl:text>&amp;width=190</xsl:text>
                  </xsl:attribute>
                </img>

              </xsl:element>
              <span><xsl:value-of select="@nodeName"/></span>
            </li>
            
          </xsl:for-each>
       </xsl:if>
      </ul>
      </xsl:template>
    </xsl:stylesheet>

    - 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.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 18, 2011 @ 10:09
    Dirk De Grave
    0

    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

    <xmp><xsl:copy-of select="mediaItems" /></xmp>

     

    Cheers,

    /Dirk

     

  • Niels 63 posts 119 karma points
    Oct 18, 2011 @ 10:31
    Niels
    0

    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

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 18, 2011 @ 10:38
    Dirk De Grave
    0

    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

  • Niels 63 posts 119 karma points
    Oct 18, 2011 @ 11:00
    Niels
    0

    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)

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 18, 2011 @ 11:09
    Dirk De Grave
    0

    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...

    Can you replace the above with following:

    <xsl:if test="string-length($source) &gt; 0">

    and see if you still get the error.

     

    Cheers,

    /Dirk

     

     

  • Niels 63 posts 119 karma points
    Oct 18, 2011 @ 11:13
    Niels
    0

    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.

    <xsl:variable name="mediaItems" select="umbraco.library:GetMedia(1179, true())"/>

    There's is no error with your latest suggestion, so that worked out very well, but there is no image displaying.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 18, 2011 @ 11:19
    Dirk De Grave
    0

    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

  • Niels 63 posts 119 karma points
    Oct 18, 2011 @ 11:19
    Niels
    0

    I'm now testing it in a template like this:

    <umbraco:Macro source="1179" Alias="Horizontalslider" runat="server"></umbraco:Macro>

    With no result...

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 18, 2011 @ 11:20
    Dirk De Grave
    0

    Also worth trying to rename your parameter, altho i don't think it'll change much in this case...

     

    Cheers,

    /Dirk

  • Niels 63 posts 119 karma points
    Oct 18, 2011 @ 11:54
    Niels
    0

    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:

    <xsl:variable name="images" select="$source/*/@id"/>

    But it doesn't work.

  • Niels 63 posts 119 karma points
    Oct 18, 2011 @ 12:07
    Niels
    1

    Yes, it worked out! The variable to get data from the macro must be a param. (codeblindness all the way). Like this:

    <xsl:variablename="source"select="/macro/source"/>

    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 ;-) )

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 18, 2011 @ 12:16
    Dirk De Grave
    0

    OMG, i didn't even see that... great find! Happy programming!

Please Sign in or register to post replies

Write your reply to:

Draft