使用XSL显示两个Sharepoint列表中的内容

时间:2014-02-18 19:10:53

标签: xslt sharepoint sharepoint-2010

我正在尝试使用XSL显示两个Sharepoint 2010列表中的内容。

第一个列表是一个简单的人员名单(名称,职称,人事照片和一个人的简短摘要)。这是对Sharepoint列表中信息的直接调用,并且工作正常。

这是事情变得棘手的地方。

我有另一个列表(Sharepoint Picture Library),其中我有6个品牌图片。

我想在图片库中显示带有人员信息的随机品牌图片,以便每次刷新页面时,我们都会看到带有随机品牌形象的人事信息。

我遇到的麻烦是1)。将图片库调用到XSL和2)。随机化内容。

如果有人能够理解我想要做的事情并且可以提供建议,我将非常感激。

- 编辑 -

这是我正在使用的XSL代码。我尝试使用response.write方法,但它炸毁了Sharepoint webpart。与javascript相同(我会很满意),但它要么不起作用,要么导致Sharepoint webpart自行内爆:

    <xsl:template name="OurStudents" match="Row[@Style='OurStudents']" mode="itemstyle">
     <xsl:variable name="LinkTarget">
        <xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
    </xsl:variable>
      <div id="body" style="margin:5px 5px 15px 5px; padding:5px; width:95%; background-image:url('../../students/PublishingImages/profiles-bg.png'); background-repeat:repeat-x; background-color:#fff;">
        <table>
        <thead>
        <div style="border:1px solid #616365; background-color:#ebebeb; padding: 5px; margin:5px;">
        <span style="font-weight:bold; font-size:12pt; margin:5px 5px 5px 5px; color:#616365;"><xsl:if test="string-length(@Name) != 0"><xsl:text> </xsl:text><xsl:value-of select="@Name"/></xsl:if></span>
        <span style="font-style:italic; font-size:10pt; margin:5px 5px 5px 5px;"><xsl:if test="string-length(@Website) != 0">(Program of Study: <a href="{substring-before(@Website,',')}" target="{$LinkTarget}" title="{@Program} Webpage"><xsl:value-of disable-output-escaping="yes" select="(@Program)"/><xsl:text></xsl:text></a>)</xsl:if></span>
        </div>
        </thead>

        <tr>
        <td>    
        <div id="photo" style="margin:5px 5px 5px 5px; padding:5px; border:1px solid #000; width:width:95%; text-align:center; background-image:url('../../students/PublishingImages/profiles-reverse-bg.png'); background-repeat:repeat-x; background-color:#867e89;">
            <xsl:choose>
                <xsl:when test="@Picture != ''">
                    <img style="border:1px solid #867e89; margin:5px 5px 5px 5px; width:200px;" src="{substring-before(@Picture,',')}" /> 
                </xsl:when>
                <xsl:otherwise>
                    <img style="border:1px solid #867e89; margin:5px 5px 5px 5px; width:125px;" src="http://www.swgc.mun.ca/PublishingImages/no-pic.jpg" alt="Picture Not Available"/>              
                </xsl:otherwise>
            </xsl:choose>
        <br></br>
        </div>
        </td>
        <td>
        <div style="margin:5px 5px 5px 5px; padding:5px; border:1px solid #000; width:94%; height:32%; background-color:#fff;">
        <xsl:if test="string-length(@About) != 0"><xsl:text> </xsl:text>
<xsl:value-of select="@About"/></xsl:if>
        </div>


<![CDATA[

<%Response.Write(string.Format("<img src='{0}/students/ERWords/{1}.jpg'/>",Microsoft.SharePoint.SPContext.Current.Site.Url,new System.Random().Next(1,6)));%>


]]>


        <img src="../../SiteAssets/Images/logos/Grenfell-logo-nu.png" width="200px" hspace="10" vspace="10" style="margin: 200px 5px 25px 250px;"></img>
        </td>
        </tr>
        </table>
    </div>
    <hr></hr>   
</xsl:template>  

0 个答案:

没有答案
相关问题