开发者

Select images from subnodes in umbraco

I have subnodes that contain an image. How do I select these and display them ? I only seem to be able to select and display the ID. The code I've used:

<xsl:value-of select="image"/>

How do I get this to display the actual image ? I'm using Umbraco 4.7. I'm sure this is simple, I just dont seem to be able to figure it out.

I have also tried this co开发者_如何学Pythonde below but it doesn't seem to look at the correct node. I think it is looking at the parent and not the child, but I'm not sure how to change this:

<xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/image, 0)" />

<xsl:if test="$media">
        <img src="{$media/umbracoFile}" alt="{$media/altText}" />
</xsl:if>


I have subnodes that contain an image. How do I select these and display them ? I only seem to be able to select and display the ID. The code I've used:

<xsl:value-of select="image"/>

Because you have forgotten to post the XML document (Learn to do this !!!) this question is impossible to answer with certainty.

My guess is that you may be more successful if you use <xsl:copy-of> instead of <xsl:value-of>

The former copies the whole node (or nodeset) specified in the select attribute, while the latter only copies the string-value of the node (nodeset).

Learn what is the difference between string value of a node-set and a copy of the nodes of a nodeset.


Use node() to get the children:

<xsl:for-each select="$currentPage/node()/image">
    <xsl:variable name="media" select="umbraco.library:GetMedia(., 0)" />
    <xsl:if test="$media">
        <img src="{$media/umbracoFile}" alt="{$media/altText}" />
    </xsl:if>
</xsl:for-each>


Try out this.

                <xsl:variable name="imageId" select="./image" />
                <xsl:if test="normalize-space($imageId)">
                    <xsl:variable name="image" select="umbraco.library:GetMedia($imageId, false())" />

                    <img src="{$image/umbracoFile}" rel="prettyPhoto" />
                </xsl:if>
            </a> 
          </xsl:if>  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜