FAQ 機能を備えた SharePoint 2010 のインターネット向け Web サイトを開発しています。
ID、タイトル (「質問」に改名)、回答、および評価用のフィールドを含むカスタム リストがあります。
次の方法でリスト ビューのレンダリングをカスタマイズするために、XSL スタイルシートを作成したいと思います。
- FAQ項目は、JQueryを使用してアコーディオンとして表示する必要があります
- 各 FAQ は、任意のユーザーが評価できます。
だから、私はこのXSLを書いた:
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt js" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:js="urn:custom-javascript" >
<xsl:import href="/_layouts/xsl/main.xsl"/>
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<script type="text/javascript" language="javascript" >
        $(document).ready(function () {
            $('#faqAnswerAccordion').accordion({
                autoHeight: false,
                collapsible: true
            });
        });
    </script>   
    <a id="top"></a>
    <div id="faqAnswerAccordion">
        <xsl:apply-templates select="//Row" mode="Item" />
    </div>
</xsl:template>
<xsl:template mode="Item" match="Row[../../@TemplateType='100']">
    <xsl:param name="Fields" select="."/>
    <xsl:param name="Collapse" select="."/>
    <xsl:param name="Position" select="1"/>
    <xsl:param name="Last" select="1"/>
    <xsl:variable name="thisNode" select="."/>
    <h3 id="header_{@ID}">
        <a id="{@ID}" href="#" ><xsl:value-of select="@Title" disable-output-escaping="yes"/></a>
    </h3>
    <div>
        <p>
            <xsl:value-of select="@Answer" disable-output-escaping="yes"/>
        </p>
        <p>
            Please rate this FAQ: 
            <xsl:apply-templates select="$Fields[@Name='AverageRating']" mode="PrintField">
                <xsl:with-param name="thisNode" select="."/>
                <xsl:with-param name="Position" select="$Position"/>
            </xsl:apply-templates>
        </p>
    </div>
</xsl:template>
そのスタイルシートでは、Jquery アコーディオンは生成されませんが、評価の星は存在します。
次のテンプレート定義を置き換えると
<xsl:template match="/">
に
<xsl:template match="View">
そのため、Jquery アコーディオンは正常に動作しますが、Rating Stars はそうではありません。
何か案は ?
どうもありがとうございます。