Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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
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.
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)"/>
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:
Here the LeftText appears while the image does not !
See my previous post, you're selecting the umbracoFile property twice.
Try posting the output of "umbraco.library:GetMedia($imageID, 0)" to the forum ...
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!
Change
<xsl:variable name="url" select="$media [@alias = 'umbracoFile']" />
<xsl:variable name="url" select="$media/data [@alias = 'umbracoFile']" />
Try doing this:
<textarea> <xsl:copy-of select="." /></textarea>
Or even better, use the package called XMLDump by Chriztian Steinmeier
<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!
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'.
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 ! :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
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
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.
Change this line
to
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 !
See my previous post, you're selecting the umbracoFile property twice.
Try posting the output of "umbraco.library:GetMedia($imageID, 0)" to the forum ...
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!
Change
to
Try doing this:
<textarea>
<xsl:copy-of select="." />
</textarea>
Or even better, use the package called XMLDump by Chriztian Steinmeier
<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!
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'.
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 ! :)
is working on a reply...