私は、指定されたノードからフォルダとそのファイル項目をリストする次のXSLTコードを持っています。XSLT xsl:apply-templates条件付き構文
これはすべて正常に動作しますが、ページのパラメータを設定し、タグ値で出力をフィルタすることもできます。
私はXLST numptyなので、私は条件式の文法に困惑しています。私は<xsl:when test="$tag">
句の下に置くべきです - 助けてもらえますか?
<xsl:variable name="tag" select="umbraco.library:Request('tag')" />
<xsl:template match="/">
<!-- Root folder in Media that holds the folders to output -->
<xsl:variable name="mediaRootFolderId" select="5948" />
<!-- Pass in true() to get XML for all nodes below -->
<xsl:variable name="mediaRootNode" select="umbraco.library:GetMedia($mediaRootFolderId, true())" />
<xsl:choose>
<xsl:when test="$tag">
</xsl:when>
<xsl:otherwise>
<!-- If we didn't get an error, output Folder elements that contain Image elements -->
<xsl:apply-templates select="$mediaRootNode[not(error)]/Folder[File]" >
<xsl:sort select="@nodeName"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Template for folders -->
<xsl:template match="Folder">
<div class="folder">
<h2>Folder: <xsl:value-of select="@nodeName" /></h2>
<div class="images">
<xsl:apply-templates select="File">
<xsl:sort select="@nodeName"/>
</xsl:apply-templates>
</div>
</div>
</xsl:template>
<!-- Template for files -->
<xsl:template match="File">
File: <a href="{umbracoFile}" alt="{@nodeName}" ><xsl:value-of select="@nodeName" /></a> <br/>
</xsl:template>
この投稿を編集して、単一引用符をバックティックに切り替える必要があります。そのため、コードスニッピの上の説明でコードが消えないようにします。バックティックはティルダと同じキーにあります。 –
良い質問、+1。私の答えは、簡単で簡単で簡単な解決策を見てください。 :) –