Copied to clipboard

Flag this post as spam?

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


  • Profiterole 232 posts 264 karma points
    Aug 24, 2011 @ 14:45
    Profiterole
    0

    getMedia from old to new schema

    Hi guys, I begin using new schema and I try to convert an xslt from old to new but it doesn't work. The code should look in a folder "cardFolder" and then display all images within.

    The working old code :

    <xsl:param name="currentPage"/>
    <
    xsl:template match="/">

    <xsl:variable name="cardFolder" select="$currentPage/data [@alias = 'cardImages']"/>

    <xsl:if test="$cardFolder &gt; 0">
      <xsl:for-each select="umbraco.library:GetMedia($cardFolder, 'false')/node">
        <xsl:variable name="imageUrl" select="./data [@alias = 'umbracoFile']"/>
        <xsl:element name="a">
          <xsl:attribute name="href">
            /formulaire-de-la-carte-virtuelle.aspx?cardID=<xsl:value-of select="$imageUrl"/>
          </xsl:attribute>
          <img src="/ImageGen.ashx?image={$imageUrl}&amp;width=200" alt="Image"/>
        </xsl:element>
      </xsl:for-each>
    </xsl:if>

    The new one that doesn't work :

    <xsl:param name="currentPage"/>
    <
    xsl:template match="/">

    <xsl:variable name="cardFolder" select="$currentPage/cardImages"/>

    <xsl:if test="$cardFolder &gt; 0">
      <xsl:for-each select="umbraco.library:GetMedia($cardFolder, 'false')/Image">
        <xsl:variable name="imageUrl" select="umbracoFile"/>
        <xsl:element name="a">
          <xsl:attribute name="href">
            /formulaire-de-la-carte-virtuelle.aspx?cardID=<xsl:value-of select="$imageUrl"/>
          </xsl:attribute>
          <img src="/ImageGen.ashx?image={$imageUrl}&amp;width=200" alt="Image"/>
        </xsl:element>
      </xsl:for-each>
    </xsl:if>

     

    I tried with : 'true', true(), 1, 'false', false(), 0 and it changes nothing. $cardFolder gives the good node number but the for-each seems not to work.

    Thank you for your help

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Aug 24, 2011 @ 14:55
    Dirk De Grave
    0

    Hi,

    At least you should pass in true() as 2nd parameter to GetMedia(), otherwise, you'd only get the current media item( which is probably a folder in your case). I always forget what gets returned but a simple xsl:copy-of should get you some details on the xml structure.

     

    <xsl:paramname="currentPage"/>
    <
    xsl:templatematch="/">

    <xsl:variablename="cardFolder"select="$currentPage/cardImages"/>
    <textarea><xsl:copy-of select="$cardFolder" />
    <xsl:iftest="$cardFolder &gt; 0">
    <xsl:for-eachselect="umbraco.library:GetMedia($cardFolder, 'false')/Image">
        <xsl:variablename="imageUrl"select="umbracoFile"/>
        <xsl:elementname="a">
          <xsl:attributename="href">
            /formulaire-de-la-carte-virtuelle.aspx?cardID=<xsl:value-ofselect="$imageUrl"/>
          </xsl:attribute>
          <imgsrc="/ImageGen.ashx?image={$imageUrl}&amp;width=200"alt="Image"/>
        </xsl:element>
      </xsl:for-each>
    </xsl:if>

     

     

    Cheers,

    /Dirk

     

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Aug 24, 2011 @ 14:59
    Chriztian Steinmeier
    0

    Hi Profiterole,

    The correct one to use would be true() or 1 - 'false' only works because a non-empy string translates to true when passed on to C#. But that's not the problem - the problem is that your for-each, somehow doesn't select any Image elements - try using a double-slash before Image (e.g.: //Image) - there was a bug in an early version which required you to do that.

    - Are you using Umbraco 4.7?

    - Maybe your media has not been converted to the new format? 

    Nevertheless - use the good old copy-of to examine what you're getting back:

    <textarea><xsl:copy-of select="umbraco.library:GetMedia($cardFolder, true())" /></textarea>

    /Chriztian

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Aug 24, 2011 @ 15:00
    Chriztian Steinmeier
    0

    *slam*

    Beaten by Dirk... :-)

  • Profiterole 232 posts 264 karma points
    Aug 25, 2011 @ 20:19
    Profiterole
    0

    Hi guys, thank you for your reply!

    Ok, I tried the copy-of just after the if test and it gives me nothing. I mean blank, no data. I pass the 2nd parameter to true(), I'm using 4.7. I tried to place directly 3203 instead of $cardFolder.

    3203, the current media, is a folder and in it there is images.

    Chriztian, I also tried the double //... And what do you mean by "convert to new media?"

    Another idea?

  • Rich Green 2246 posts 4006 karma points
    Aug 26, 2011 @ 00:49
    Rich Green
    1

    Hey,

    Try to republish your media.

    You can use this URL /umbraco/dialogs/republish.aspx?xml=true

    rich

  • Profiterole 232 posts 264 karma points
    Aug 26, 2011 @ 01:30
    Profiterole
    0

    Rich, thank a lot!! Another new tool you made me discover!

    Thank you all, now it works!

  • 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