문제

나는 Umbraco의 XSLT 시스템을 사용하기 시작했습니다. 여기서 모든 미디어를 특정 미디어 디렉토리 아래에 나열 한 매크로를 제작하고자했습니다. 나는 umbraco.library : getmedia를 발견했지만 솔직히, 나는 아이템 목록을 얻기 위해 무엇을 전달 해야하는지 전혀 모른다. API 문서 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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top