2009-09-18 80 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>