[英]Umbraco library getMedia parent node property xslt
How can I get a property from the parent node of a media item using "umbraco.library:GetMedia"? 如何使用“ umbraco.library:GetMedia”从媒体项目的父节点获取属性?
This allows me to get the current nodes "@nodeName" 这使我可以获取当前节点“ @nodeName”
<xsl:value-of select="umbraco.library:GetMedia(., 0)/@nodeName" />
I want to get the parent of the current nodes "@nodeName", I've tried the following but it doesn't work: 我想获取当前节点“ @nodeName”的父级,我尝试了以下操作,但不起作用:
<xsl:value-of select="umbraco.library:GetMedia(., 0)/../@nodeName" />
Can anyone help me out? 谁能帮我吗?
Cheers, JV 欢呼声,合资企业
With a call to GetMedia() and the @parentID attribute in a variable, I've got it working using the following: 通过调用GetMedia()和变量中的@parentID属性,我可以使用以下命令使其工作:
<xsl:template match="/">
<!-- Do not call unless an image was picked -->
<xsl:apply-templates select="$currentPage/image[normalize-space()]" />
</xsl:template>
<xsl:template match="image">
<!-- Note: These WILL fail if no media is selected -->
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia(., false())" />
<xsl:variable name="parentMedia" select="umbraco.library:GetMedia($mediaNode/@parentID, false())" />
<p>
Media: <xsl:value-of select="$mediaNode/@nodeName" />
</p>
<p>
Parent: <xsl:value-of select="$parentMedia/@nodeName" />
</p>
</xsl:template>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.