Copied to clipboard

Flag this post as spam?

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


  • sanu 5 posts 25 karma points
    Dec 01, 2010 @ 12:23
    sanu
    0

    umbraco.library:GetMedia : Does not list media from document types

    Hi,

    I have an XSLT script, where I want to list all images / text under a particular section .

    I have attahed an image to this documentype as a property which is a Media Picker type.

    Under my xslt, i have thhis loop to go through all the items added under a particular node. ::

    <ul>
                <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=1]/node [@nodeName = 'leftpanel']">
                    <xsl:for-each select="current()/descendant-or-self::node [@level=2]/node [@nodeName = 'Items']">
                <xsl:for-each select="current()/descendant-or-self::node [@level=3]//child::node">
                    <ul>   
                    <xsl:choose>
                        <xsl:when test="@nodeTypeAlias = 'LeftPanelItem'">
                              <xsl:variable name="imageID">
                                  <xsl:choose>
                                   <xsl:when test="data[@alias='Thumb'] != ''"><xsl:value-of select="data[@alias='Thumb']" /></xsl:when>
                                   <xsl:otherwise>6600</xsl:otherwise>
                                  </xsl:choose>
                                 </xsl:variable>
                <xsl:variable name="media" select="umbraco.library:GetMedia($imageID, 0)/data [@alias = 'umbracoFile']"/>
                            <xsl:variable name="url" select="$media [@alias = 'umbracoFile']" />
                        <li><img src="{$url}" alt="{$imageID}"/></li>
                        </xsl:when>
                    </xsl:choose>
                    </ul>                   
                </xsl:for-each>
            </xsl:for-each>
                </xsl:for-each>
            </ul>

    Now : the output is showing only the image with media id :6600 from the otherwise section!! WHile there are other images under the THUMB type !

    The LeftPanelItem is as this:

    One of the items under the for-loop has the item as :

    umbraco v 4.0.2.1 (Assembly version: 1.0.3441.17657)

    Any suggestions / solutions would be very much appreciated !!!

    Thanks in advance!

    Sanu

  • Sebastian Dammark 583 posts 1407 karma points
    Dec 01, 2010 @ 12:49
    Sebastian Dammark
    1

    Try doing like this inside your when:

    <xsl:value-of select="data[@alias='Thumb']/@id" />

    I'm not sure it will work since the XSLT is a bit confusing.

  • Chris Koiak 700 posts 2626 karma points
    Dec 01, 2010 @ 13:01
    Chris Koiak
    0

    Change this line

    <xsl:variable name="media" select="umbraco.library:GetMedia($imageID, 0)/data [@alias = 'umbracoFile']"/>

    to

    <xsl:variable name="media" select="umbraco.library:GetMedia($imageID, 0)"/>
  • sanu 5 posts 25 karma points
    Dec 01, 2010 @ 13:03
    sanu
    0

    Thank You so much for the immediete response.... in fact to make the xslt simpler:

    The LeftPanelItem which is created has a text and an image. Both mandatory!

    The node is the LeftPanelitem. I am able to get the Text value. I have the image along with this, but the media id is not getting retrieved,

    The normal xslt would be sometihng like:

     

         <ul>   
          <xsl:choose>
          <xsl:when test="@nodeTypeAlias = 'LeftPanelItem'">
              <xsl:variable name="imageID">
              <xsl:value-of select="data[@alias='Thumb']/@id" /></xsl:variable>
             

            <xsl:variable name="media" select="umbraco.library:GetMedia($imageID, 0)/data [@alias = 'umbracoFile']"/>

             
              <xsl:variable name="url" select="$media [@alias = 'umbracoFile']" />
             
              <li><img src="{$url}" alt="{$imageID}"/></li>
              <li><a><xsl:value-of select="data[@alias='LeftText']" /></a></li>
          </xsl:when>
          </xsl:choose>
      </ul>

    Here the LeftText appears while the image does not !


  • Chris Koiak 700 posts 2626 karma points
    Dec 01, 2010 @ 13:09
    Chris Koiak
    0

    See my previous post, you're selecting the umbracoFile property twice.

  • Sebastian Dammark 583 posts 1407 karma points
    Dec 01, 2010 @ 13:12
    Sebastian Dammark
    1

    Try posting the output of "umbraco.library:GetMedia($imageID, 0)" to the forum ...

  • sanu 5 posts 25 karma points
    Dec 01, 2010 @ 13:17
    sanu
    0

    Hi Chris:

    Thank You! ..

    When i did the change as you said , the img source string gets appended gaiag with the image name !

    Eg: /media/170595/tm_siegel_2009.png16015615295png

    16015615295png is extra !

    and taking the extra text in firebug shows the image !

    What would be wrong?

    Though 6600 imageid image is taken ! Still not from the LeftPanel item!

  • Chris Koiak 700 posts 2626 karma points
    Dec 01, 2010 @ 13:25
    Chris Koiak
    0

    Change

     <xsl:variable name="url" select="$media [@alias = 'umbracoFile']" />

    to

     <xsl:variable name="url" select="$media/data [@alias = 'umbracoFile']" />
  • Sebastian Dammark 583 posts 1407 karma points
    Dec 01, 2010 @ 13:25
    Sebastian Dammark
    0

    Try doing this:

    <textarea>
      <xsl:copy-of select="." />
    </textarea>

    Or even better, use the package called XMLDump by Chriztian Steinmeier

  • sanu 5 posts 25 karma points
    Dec 01, 2010 @ 13:34
    sanu
    0

      <xsl:variable name="imageID"><xsl:value-of select="data[@alias='Thumb']/@id" /></xsl:variable>

    Returns nothing! its blank!

    The jist of the issue is : A item of type 'LeftPanelItem' document type , which had a content with mediapicker , does not return the media id of the same!

  • Sebastian Dammark 583 posts 1407 karma points
    Dec 01, 2010 @ 13:51
    Sebastian Dammark
    0

    Yeah, but please let us see your XML.

    If this 'data[@alias='Thumb']/@id' returns blank, it means the the current element doesn't have a data child with the attribute @alias = 'Thumb'.

     

  • sanu 5 posts 25 karma points
    Dec 01, 2010 @ 14:23
    sanu
    0

    Thank You All ....

    It just got solved! The dumping xml worked and was able to understand the issue !

    More to do with frequent changing of the documenttype structure! The old nodes were getting listed in the xml !

    Had to repopulate the doumnet type items once again for the changed structure !

    Happy bird ! :)

  • 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