0

我正在尝试使用 xslt 创建一个动态图库并搜索了论坛,但似乎找不到任何具有相同问题的线程。这个想法是,用户可以从各个内容页面上的媒体选项卡中选择最多 6 张图片,以便在不同页面上可以有不同的画廊。该文件正确保存,我没有收到任何错误,但是当页面加载时没有显示任何内容。

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>
4

1 回答 1

0

最终为这个问题采取了不同的路线。无需将图像添加到媒体选项卡,然后从内容页面单独选择它们,这允许用户只需选择整个文件夹并以这种方式创建图库。

<!-- 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>
于 2014-02-10T18:29:43.223 回答