简体   繁体   English

xslt getMedia Umbraco宏

[英]xslt getMedia Umbraco macro

I'm trying to create a dynamic gallery with xslt and have searched the forums but can't seem to find any threads with the same problem. 我正在尝试使用xslt创建一个动态库并搜索了论坛,但似乎找不到具有相同问题的任何主题。 The idea is that users can select up to 6 pictures from the media tab on the individual content pages so that there can be different galleries on different pages. 这个想法是,用户可以从各个内容页面的“媒体”选项卡中选择最多6张图片,以便在不同页面上可以有不同的画廊。 The file saves correctly, and I'm not receiving any errors, but when the page loads nothing is displayed. 该文件正确保存,并且我没有收到任何错误,但是在页面加载时未显示任何内容。

The xslt xslt

<xsl:if test="$currentPage/image &gt; 0">
    <xsl:variable name="gal1" select="umbraco.library:GetMedia($currentPage/galimg1, false())" />
    <xsl:variable name="gal2" select="umbraco.library:GetMedia($currentPage/galimg2, false())" />
    <xsl:variable name="gal3" select="umbraco.library:GetMedia($currentPage/galimg3, false())" />
    <xsl:variable name="gal4" select="umbraco.library:GetMedia($currentPage/galimg4, false())" />
    <xsl:variable name="gal5" select="umbraco.library:GetMedia($currentPage/galimg5, false())" />
    <xsl:variable name="gal6" select="umbraco.library:GetMedia($currentPage/galimg6, false())" />

    <xsl:if test="not($gal1/error)">
         <xsl:variable name="url" select="$gal1/umbracoFile" />
         <a rel="prettyPhoto [gallery]" href="{$url}">
         <img src="{$url}" />
         </a>
    </xsl:if>
    <xsl:if test="not($gal2/error)">
        <xsl:variable name="url" select="$gal2/umbracoFile" />
        <a rel="prettyPhoto [gallery]" href="{$url}">
        <img src="{$url}" />
        </a>
    </xsl:if>
    <xsl:if test="not($gal3/error)">
         <xsl:variable name="url" select="$gal3/umbracoFile" />
         <a rel="prettyPhoto [gallery]" href="{$url}">
         <img src="{$url}" />
         </a>
    </xsl:if>
    <xsl:if test="not($gal4/error)">
         <xsl:variable name="url" select="$gal4/umbracoFile" />
         <a rel="prettyPhoto [gallery]" href="{$url}">
         <img src="{$url}" />
         </a>
    </xsl:if>
    <xsl:if test="not($gal5/error)">
        <xsl:variable name="url" select="$gal5/umbracoFile" />
        <a rel="prettyPhoto [gallery]" href="{$url}">
        <img src="{$url}" />
        </a>
    </xsl:if>
    <xsl:if test="not($gal6/error)">
        <xsl:variable name="url" select="$gal6/umbracoFile" />
        <a rel="prettyPhoto [gallery]" href="{$url}">
        <img src="{$url}" />
        </a>
    </xsl:if>
</xsl:if>

Ended up going a different route for this issue. 最终为此问题走了一条不同的路线。 Rather than adding the images to the media tab and then selecting them individually from the content page, this allows users to just select an entire folder and creates the gallery that way. 与其将图像添加到“媒体”选项卡,然后从内容页面中单独选择它们,不如让用户选择整个文件夹并以这种方式创建图库。

<!-- Displays all images from a folder in the Media Library -->
<xsl:if test="number($mediaFolderId)">
    <div class="galleryContainer">
        <xsl:for-each select="umbraco.library:GetMedia($mediaFolderId, true())/Image">
            <xsl:if test="umbracoFile !=''">
                <a href="{umbracoFile}" title="{umbracoDescription}" rel="prettyPhoto [gallery]">
                    <img class="galleryWatermark" src="/images/logo_watermark.png" alt="{@nodeName}" title="{@nodeName}" style="background:url({umbracoFile}) top no-repeat; background-size:180px; width:100%; height:100%;" />
                </a>
            </xsl:if>
        </xsl:for-each>
    </div>
</xsl:if>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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