繁体   English   中英

检索umbraco中的媒体列表

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM