[英]Retrieving a list of media in umbraco
我剛剛開始在umbraco中使用XSLT系統,在那里我希望產生一個宏,該宏列出了特定媒體目錄下的所有媒體。 我遇到過umbraco.library:GetMedia,但是坦率地說,我不知道要傳遞給它什么才能獲得項目列表。 http://umbraco.org/apiDocs/html/M_umbraco_library_GetMedia.htm上的API文檔似乎暗示我可能想要查找一個節點(如何?),然后將其傳遞給
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>
這是相同的代碼,但已更新為可與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>
多虧了在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>
以及頁面上的媒體選擇器控件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.