Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Aug 06, 2010 @ 17:11
    Ismail Mayat
    0

    mediaCurrent macro issue in 4.5.1

    Hello,

    I have a macro it takes one property of type mediaCurrent.  I add the macro to rich text editor field and pick a folder.  In the xslt i am doing the following

    <xsl:variable name="folderToShow" select="/macro/folderToShow"/>

    <xsl:template match="/">
      <xsl:copy-of select="umbraco.library:GetMedia(1075, true())"/>
      <xsl:value-of select="$folderToShow"/>
      <xsl:if test="$folderToShow!=''">
        <xsl:copy-of select="umbraco.library:GetMedia($folderToShow, true())"/>
      </xsl:if>


    </xsl:template>

    When i do direct GetMedia using the id selected in this 1075 i get some stuff back however attempting to use the value passed in i dont get anything because folderToShow seems to be empty any ideas?

    Regards

    Ismail

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Aug 06, 2010 @ 17:13
    Matt Brailsford
    0

    Doesn't mediaCurrent already return a media item? rather than it's ID?

    Matt

  • Tom Maton 387 posts 659 karma points
    Aug 06, 2010 @ 17:18
    Tom Maton
    0

    try this macro call:

    <xsl:variable name="folderToShow" select="/macro/folderToShow/*/@id"/>

    This is what I've done recently or

    <xsl:variable name="folderToShow" select="/macro/folderToShow/Image/@id"/>

     

    Thanks

    Tom

  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Aug 06, 2010 @ 17:19
    Ismail Mayat
    0

    Matt,

    Then

      <xsl:copy-of select="$folderToShow"/>

    Should give me something as xml structure which it doesnt.  I thought it might me because its in rich text editor but i get same result in template.

    Regards

    Ismail

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Aug 06, 2010 @ 17:23
    Matt Brailsford
    0

    @Tom - Surely in Ismails context this is a waist? If /macro/folderToShow is already a media node (which I belive is what mediaCurrent returns), you are pulling back the id only to do another GetMedia. He should just be able to do:

    <xsl:variable name="folderToShow" select="/macro/folderToShow"/>

    <xsl:template match="/">
      <xsl:value-of select="$folderToShow/umbracoFile"/>
    <xsl:template> 

    Matt

  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Aug 06, 2010 @ 17:25
    Ismail Mayat
    0

    Tom,

    Tried that no joy.  I do recall seeing this before it just would not pass the param through.

    Regards

    Ismail

  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Aug 06, 2010 @ 17:26
    Ismail Mayat
    0

    Matt,

    Its a folder that I am picking and want to list the children.

    Regards

    Isamil

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Aug 06, 2010 @ 17:26
    Matt Brailsford
    0

    @Ismail - Checkout this page

    http://umbraco.org/documentation/books/macro-parameters-syntax

    Its says

    mediaCurrent - the xml of the selected media item

    Matt

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Aug 06, 2010 @ 17:29
    Matt Brailsford
    0

    Does this not work to list all images?

    <xsl:variable name="folderToShow" select="/macro/folderToShow"/>

    <xsl:template match="/">
      <xsl:for-each select="$folderToShow/*[name() = 'Image']">
    ...


    </xsl:for-each>
    <xsl:template>

    Matt

  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Aug 06, 2010 @ 17:32
    Ismail Mayat
    0

    Matt,

    Nope get nothing it seems as though the value is not being passed through /macro/folderToShow

    Regards

    Ismail

  • Tom Maton 387 posts 659 karma points
    Aug 06, 2010 @ 17:42
    Tom Maton
    0

    What about removing the * or media type from the select? eg

    <xsl:variable name="folderToShow" select="/macro/folderToShow/@id"/>

    As I'm doing exaclty the same thing on one of my clients sites and seems to be working no problem...

    Thanks

    Tom

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Aug 06, 2010 @ 18:52
    Matt Brailsford
    0

    Ok, I just set it up in my test 4.5.1 instance. Given the following XSLT

    <xsl:variable name="folderToShow" select="/macro/folderToShow"/>

    <xsl:template match="/">
      
      <textarea>
        <xsl:copy-of select="$folderToShow" />
      </textarea>

    </xsl:template>

    I get the following output when folderToShow is pointed to a folder full of images

    <folderToShow>
    <Folder id="1090" version="e6100ed1-4649-410a-9f5e-20a4a07293ee" parentID="1076" level="2" writerID="0" nodeType="1031" template="0" sortOrder="3" createDate="2010-07-29T19:29:26" updateDate="2010-07-29T19:29:27" nodeName="Cats" urlName="cats" writerName="Administrator" nodeTypeAlias="Folder" path="-1,1076,1090">
    <contents />
    </Folder>
    </folderToShow>

    Which suggests that it doesn't pull back  the contents, rather just the xml for the selected node, which means Tom is right, either of the following should work.

    <xsl:variable name="folderToShow" select="/macro/folderToShow/Folder/@id"/>

    or

    <xsl:variable name="folderToShow" select="/macro/folderToShow/*/@id"/>

    Matt

  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Aug 09, 2010 @ 10:33
    Ismail Mayat
    0

    Matt,

    This is now working totally bloody bizarre. 

    Regards

    Isamil

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Aug 09, 2010 @ 10:36
    Matt Brailsford
    0

    You live an learn =)

    Matt

  • marcelh 171 posts 471 karma points
    Aug 11, 2010 @ 14:16
    marcelh
    0

    I have been struggling with the same problem this morning, and appearently the folder, or better said Folder is case sensitive.

    Instead of

    <xsl:param name="mediaFolderID" select=/macro/mediaFolder/folder/@id />

    This did the trick

    <xsl:param name="mediaFolderID" select="/macro/mediaFolder/Folder/@id" />

    Just as

    <xsl:param name="mediaFolderID" select=/macro/mediaFolder/*/@id />

    With the latter I eventually found out that Folder was case sensitive and spelled with a capital F

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

Please Sign in or register to post replies