题
我刚开始用一把umbraco的XSLT系统,我希望能生产出列出的特定媒体目录下的所有媒体宏来演。我所遇到umbraco.library:GetMedia但是,坦率地说,我不知道该怎么传递给它,以获得项目的列表。在 http://umbraco.org/apiDocs/html/M_umbraco_library_GetMedia.htm似乎暗示着什么,我想大概是看一个节点(如何?),然后用
umbraco.library:GetMedia(<some node id>, true)
我将如何去获得,最初的节点ID?
随后将这样的工作?
<xsl:for-each select="umbraco.library:GetMedia(<SOMEMAGIC>, 'true')">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
解决方案 2
由于从乡亲一些很大的帮助了在一把umbraco论坛,我想通了。线程是这里和溶液基本上是这样的XSLT
<xsl:for-each select="umbraco.library:GetMedia($currentPage/data [@alias='mediaDir'], 'true')/node">
<li>
<xsl:choose>
<xsl:when test="umbraco.library:GetMedia(@id, 'false')/data [@alias = 'umbracoFile']">
<a><xsl:attribute name="href">
<xsl:value-of select="umbraco.library:GetMedia(@id, 'false')/data [@alias = 'umbracoFile']"/>
</xsl:attribute>
<xsl:value-of select="@nodeName"/>
</a>
</xsl:when>
<xsl:otherwise>
<!--Do something with the directory-->
</xsl:otherwise>
</xsl:choose>
</li>
</xsl:for-each>
加上网页上的媒体选择器控制。
其他提示
下面是相同的代码,但与更新一把umbraco 4.5或更高的工作:
<xsl:variable name="images" select="umbraco.library:GetMedia($currentPage/mediaDir, 1)" />
<xsl:for-each select="$images/*">
<li>
<xsl:choose>
<xsl:when test="string(local-name()) = 'Image'">
<a>
<xsl:attribute name="href">
<xsl:value-of select="./umbracoFile"/>
</xsl:attribute>
<xsl:value-of select="@nodeName"/>
</a>
</xsl:when>
<xsl:otherwise>
<!--Do something with the directory-->
</xsl:otherwise>
</xsl:choose>
</li>
</xsl:for-each>
不隶属于 StackOverflow