Modify List Style Through XSL

In MOSS,list is ultimately stored in the database in the format of xml.

Now we can Modify list style through XSL.Fowlling the steps under below.

 

1.       Create a custom list named podcasts.

2.       Create a new page(A.aspx)  with Blank Web Part Page Layout. Then Drag this podcasts list into webpart zone of this page. DataView  Webpart will show all datas about this podcasts list. Modify to show fields that needed.

3.       Then  copy XSLT code in DataView Webpart,  modified the xslt code.

 

xslt code:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<

 

 

 

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 " 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:ddwrt2 = " urn:frontpage:internal "

>

<

 

 

 

xsl:output method = " html " indent = " no "

/>

<

 

 

 

xsl:decimal-format NaN = ""

/>

<

 

 

 

xsl:param name = " dvt_apos " > &apos; </ xsl:param

>

<

 

 

 

xsl:variable name = " dvt_1_automode " > 0 </ xsl:variable

>

<

 

 

 

xsl:template match = " / "

>

<

 

 

 

xsl:call-template name = " dvt_1 "

/>

</

 

 

 

xsl:template

>

<

 

 

 

xsl:template name = " dvt_1 "

>

<

 

 

 

xsl:variable name = " dvt_StyleName " > Table </ xsl:variable

>

<

 

 

 

xsl:variable name = " Rows " select = " /dsQueryResponse/Rows/Row "

/>

<

 

 

 

table border = " 0 " width = " 100% " cellpadding = " 2 " cellspacing = " 0 "

>

<

 

 

 

xsl:call-template name = " dvt_1.body "

>

<

 

 

 

xsl:with-param name = " Rows " select = " $Rows "

/>

</

 

 

 

xsl:call-template

>

</

 

 

 

table

>

</

 

 

 

xsl:template

>

<

 

 

 

xsl:template name = " dvt_1.body "

>

<

 

 

 

xsl:param name = " Rows "

/>

<

 

 

 

xsl:for-each select = " $Rows "

>

<

 

 

 

xsl:call-template name = " dvt_1.rowview "

/>

</

 

 

 

xsl:for-each

>

</

 

 

 

xsl:template

>

<

 

 

 

xsl:template name = " dvt_1.rowview "

>

<

 

 

 

tr

>

<

 

 

 

xsl:if test = " position() mod 2 = 1 "

>

<

 

 

 

xsl:attribute name = " class " > ms-alternating </ xsl:attribute

>

</

 

 

 

xsl:if

>

<

 

 

 

td class = " ms-vb " width = " 1% " nowrap = "" rowspan = " 3 "

>

<

 

 

 

a

>

<

 

 

 

xsl:attribute name = " href "

>

/B.aspx?itemId=

 

 

< xsl:value-of select = " @ID "

/>

</

 

 

 

xsl:attribute

>

<

 

 

 

img border = " 0 " width = " 50 " height = " 50 " src = " {substring-before(@Picurl, ', ')} " alt = " {substring-after(@Picurl, ', ')} "

/>

</

 

 

 

a

>

</

 

 

 

td

>

<

 

 

 

td class = " ms-vb "

>

<

 

 

 

xsl:value-of select = " @Title "

/>

</

 

 

 

td

>

</

 

 

 

tr

>

<

 

 

 

tr

>

<

 

 

 

td style = " font-size:12px; "

>

<

 

 

 

xsl:value-of select = " ddwrt:FormatDateTime(string(@Created) ,1033 ,'MMMM dd, yyyy ') "

/>

</

 

 

 

td

>

</

 

 

 

tr

>

<

 

 

 

tr

>

<

 

 

 

td style = " font-size:12px; "

>

<

 

 

 

xsl:choose

>

<

 

 

 

xsl:when test = " string-length(@Description) &gt; 80 "

>

<

 

 

 

xsl:value-of select = " substring(@Description, 1,77) " disable-output-escaping = " yes "

/>

</

 

 

 

xsl:when

>

<

 

 

 

xsl:otherwise

>

<

 

 

 

xsl:value-of select = " @Description " disable-output-escaping = " yes "

/>

</

 

 

 

xsl:otherwise

>

</

 

 

 

xsl:choose

>

</

 

 

 

td

>

</

 

 

 

tr

>

</

 

 

 

xsl:template

>

</

 

 

 

xsl:stylesheet

>

 

referrence:

http://www.cnblogs.com/jaxu/archive/2009/08/18/1548259.html

New: <img alt="" border   ="0">  
      <xsl:attribute   name="src">
    ../../Style Library/Images/<xsl:value-of select="substring-before(substring-after($Url,'/'),'/')"/>/en.JPG</xsl:attribute>
  </img>

 

 

 

http://www.cnblogs.com/jaxu/archive/2009/08/18/1548259.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值