Copied to clipboard

Flag this post as spam?

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


  • Kelsee Ishmael 71 posts 158 karma points
    Nov 04, 2010 @ 18:56
    Kelsee Ishmael
    0

    GetMedia New XSLT Syntax Issues

    I had a xslt function that I was using in the old syntax. It was basically a gallery and it worked great. Now, I upgraded and am using the new syntax. Some things are working properly, but I'm having a problem with a little piece of code.

    Below is an example of a piece of code that grabs $mediaFolderID, which is the id of a media folder - 1109 for example, and executes a command for every folder underneath the $mediaFolderID.

    old:

    <xsl:for-each select="umbraco.library:GetMedia($mediaFolderID, '0')/node [@nodeTypeAlias = 'Folder']">

    new:

    <xsl:for-each select="umbraco.library:GetMedia($mediaFolderID, '0')/Folder [@isDoc]">

     

    From what I gather, the new code should do the same thing, but it isn't. It doesn't seem to recognize anything and doesn't seem to be finding any folders under this media id.

    Any suggestions?

    Thanks so much!

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 04, 2010 @ 19:16
    Tom Fulton
    0

    I don't think the Media area uses @isDoc - try removing that and I believe it will work

  • Kelsee Ishmael 71 posts 158 karma points
    Nov 04, 2010 @ 19:28
    Kelsee Ishmael
    0

    If I remove the @isDoc, I get the same issue.

    I have also tried using the direct id, to remove extra variables that could cause issues. Below are some other things I have tried.

    <xsl:for-each select="umbraco.library:GetMedia(1109, 0)/Folder">
    <xsl:for-each select="umbraco.library:GetMedia(1109, false())/Folder">

     

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 04, 2010 @ 19:30
    Tom Fulton
    0

    Hmm..I tested here and it seems to work.  Try writing out the results of GetMedia into a textarea with copy-of, so you can see the XML that gets generated:

    <textarea><xsl:copy-of select="umbraco.library:GetMedia(1109, 0)/Folder" /></textarea>
  • Kelsee Ishmael 71 posts 158 karma points
    Nov 04, 2010 @ 20:54
    Kelsee Ishmael
    0

    Still not getting anything. I've simplified my code for the purpose of the forum. Here is all of it.

     

    <?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" 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:template match="/">
    <textarea>INFO: <xsl:copy-of select="umbraco.library:GetMedia(1096, 0)/Folder" /></textarea>
    <xsl:for-each select="umbraco.library:GetMedia(1096, 0)/Folder">TEST</xsl:for-each>
    </xsl:template>

    </xsl:stylesheet>
  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 04, 2010 @ 20:58
    Tom Fulton
    0

    Add quotes around the second parameter in GetMedia and you should be good

    <xsl:for-each select="umbraco.library:GetMedia(1096, '0')/Folder">TEST</xsl:for-each>
  • Kelsee Ishmael 71 posts 158 karma points
    Nov 04, 2010 @ 21:00
    Kelsee Ishmael
    0

    Still not working, sadly. I appreciate all the suggestions. Is it possible that a faulty install might cause issues? I'm not sure what else it could be.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 04, 2010 @ 21:04
    Tom Fulton
    0

    That's odd, it is working for me.  Actually....are you on 4.5.2 or 4.5.0 or 4.5.1?  I think there were some changes to the media XML structure between them.

    Also, are you getting anything in your textarea after adding the '0'?  If not, try removing /Folder and paste the results here

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 04, 2010 @ 21:24
    Tom Fulton
    0

    In 4.5.0 or .1 (can't remember which one), it might be something like .../*/Folder instead of .../Folder...but you should be able to see what's going on once you get the results in the textarea

  • Kelsee Ishmael 71 posts 158 karma points
    Nov 04, 2010 @ 21:30
    Kelsee Ishmael
    0

    I'm in 4.5.2.

    I tried using '0' - nothing. I tried removing "/Folder" and still nothing. Here is what I have currently, and I'm not getting anything.

    <xsl:template match="/">
    <textarea>INFO1: <xsl:copy-of select="umbraco.library:GetMedia(1096, '0')/*/Folder" /></textarea>
    <textarea>INFO2: <xsl:copy-of select="umbraco.library:GetMedia(1096, '0')" /></textarea>
    <textarea>INFO3: <xsl:value-of select="name(umbraco.library:GetMedia(1096, ''))"/></textarea>
    <xsl:for-each select="umbraco.library:GetMedia(1096, '0')/Folder">TEST</xsl:for-each>
    <xsl:for-each select="umbraco.library:GetMedia(1096, '0')/*">TEST</xsl:for-each>
    </xsl:template>

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 04, 2010 @ 21:52
    Jan Skovgaard
    0

    Hi Kaifish

    Are you sure the new installtion is using the new XML schema? Have you tried to republish the specified folder and it's children? Try to republish all nodes under the "content" section.

    Have you tried recycling the app pool or just reset the IIS?

    Are you having other problems with the installation?

    /Jan

     

  • Kelsee Ishmael 71 posts 158 karma points
    Nov 04, 2010 @ 21:56
    Kelsee Ishmael
    0

    Wow, I can't believe that was it. I had to republish everything in the media folder. (Manually sadly since there isn't a master republish).

    Thank you so much! Very helpful!

    Also, sorry Tom that we had to go through all of that and that was what the problem was..

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 04, 2010 @ 22:02
    Jan Skovgaard
    0

    Yes, it's actually a bit frustrating. Maybe that would be a good suggestion for v5 - there is a post about it somewhere in the forum. It's worth suggesting if someone has not done so already.

    Happy you got it all solved - One can be so frustrated sometimes :-)

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 04, 2010 @ 22:06
    Jan Skovgaard
    1

    btw...

    I'm asuming you want to fetch all the images in the specified folder. To to so, if i'm not mistaken, you'll actually need to 

    write either umbraco.library:GetMedia(1096,1), which returns true and then returns all the subnodes. I think that you can also use umbraco.library:GetMedia(1096,true()) - if you pass 0 as a string, like '0', it's interpreted as "true". If you just pass 0 it'll return false and you'll only get the XML of the folder.

    /Jan

  • Tommy Poulsen 514 posts 708 karma points
    Nov 04, 2010 @ 22:16
    Tommy Poulsen
    2

    You can run this:

    /umbraco/dialogs/republish.aspx?xml=true

    to re-publish all nodes incl. media

    >Tommy

     

  • Kelsee Ishmael 71 posts 158 karma points
    Nov 04, 2010 @ 22:17
    Kelsee Ishmael
    0

    Thanks, I will try that :)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 04, 2010 @ 22:18
    Jan Skovgaard
    0

    Great tip Tommy - #H5YR :-)

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 05, 2010 @ 01:53
    Tom Fulton
    0

    Jan to the rescue!  Also thanks for clarifying the '0' thing

Please Sign in or register to post replies

Write your reply to:

Draft