2009-09-18 112 views
2

检索的媒体名单我刚开始用一把umbraco的XSLT系统,我希望能生产出列出的特定媒体目录下的所有媒体宏来演。我遇到了umbraco.library:GetMedia但坦率地说,我不知道要传递给它以获取项目列表。在http://umbraco.org/apiDocs/html/M_umbraco_library_GetMedia.htm API文档似乎表明,我可能想的是看一个节点(如何?),然后用在一把umbraco

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> 

回答

0

感谢人们在umbraco论坛上的一些很大的帮助,我想出了它。线程是here并将该溶液基本上是这样的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> 

加上网页上的媒体选择器控制。

+1

这并不适用于一把umbraco 4.5及以上工作了。 http://www.notas-terrible.net/blog/post/Umbraco-45-XML-Schema-changed.aspx – Costo 2011-07-22 20:14:54

+0

Costo,您的链接不起作用 – Mario 2011-11-10 00:48:38

1

这是同样的代码,但是更新了一把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>