在SP的开发过程中,有的时候首页需要一些webpart来显示子网站的内容,显示一个标题,可以链接的,还有tooltip的,开始的时候我用content qeury web part ,后来发现他默认只能显示标题,什么时间啊,用户名啊,什么的都不能显示。
过一段时间发现,我错误了,那个控件还是很强大的,详见微软的官网http://msdn.microsoft.com/en-us/library/bb447557.aspx。
可以定制的,不过是用到处webpart文件,声明要使用的栏目,然后编写xslt,定义显示的格式,可以多列,可以自定义一些东西,不错。
园子里面已经有很多的文章了,我就不写步骤了。留个标记。
<
xsl:template
name
="ForumStyle"
match
="Row[@Style='ForumStyle']"
mode
="itemstyle"
>
< xsl:variable name ="SafeLinkUrl" >
< xsl:call-template name ="OuterTemplate.GetSafeLink" >
< xsl:with-param name ="UrlColumnName" select ="'LinkUrl'" />
</ xsl:call-template >
</ xsl:variable >
< xsl:variable name ="DisplayTitle" >
< xsl:call-template name ="OuterTemplate.GetTitle" >
< xsl:with-param name ="Title" select ="@Title" />
< xsl:with-param name ="UrlColumnName" select ="'LinkUrl'" />
</ xsl:call-template >
</ xsl:variable >
< xsl:variable name ="LinkTarget" >
< xsl:if test ="@OpenInNewWindow = 'True'" > _blank </ xsl:if >
</ xsl:variable >
< div id ="linkitem" class ="item link-item" >
< table >
< tr >
< td width ="200px" >
< xsl:if test ="string-length($DisplayTitle) = 0" >
< a href =" {$SafeLinkUrl} " target =" {$LinkTarget} " title =" {@Title} " >
< xsl:value-of select ="$DisplayTitle" />
</ a >
</ xsl:if >
< xsl:if test ="string-length($DisplayTitle) <= 10" >
< a href =" {$SafeLinkUrl} " target =" {$LinkTarget} " title =" {@Title} " >
< xsl:value-of select ="$DisplayTitle" />
</ a >
</ xsl:if >
< xsl:if test ="string-length($DisplayTitle) > 10" >
< a href =" {$SafeLinkUrl} " target =" {$LinkTarget} " title =" {@Title} " >
< xsl:value-of select ="substring($DisplayTitle,1,9)" />
</ a >
</ xsl:if >
</ td >
< td width ="100px" >
< xsl:value-of select ='substring(@Modified,1,4)' ></ xsl:value-of >
</ td >
< td align ="right" > 回复数量:
< xsl:value-of select ="@ItemChildCount" />
</ td >
</ tr >
</ table >
</ div >
</ xsl:template >
< xsl:variable name ="SafeLinkUrl" >
< xsl:call-template name ="OuterTemplate.GetSafeLink" >
< xsl:with-param name ="UrlColumnName" select ="'LinkUrl'" />
</ xsl:call-template >
</ xsl:variable >
< xsl:variable name ="DisplayTitle" >
< xsl:call-template name ="OuterTemplate.GetTitle" >
< xsl:with-param name ="Title" select ="@Title" />
< xsl:with-param name ="UrlColumnName" select ="'LinkUrl'" />
</ xsl:call-template >
</ xsl:variable >
< xsl:variable name ="LinkTarget" >
< xsl:if test ="@OpenInNewWindow = 'True'" > _blank </ xsl:if >
</ xsl:variable >
< div id ="linkitem" class ="item link-item" >
< table >
< tr >
< td width ="200px" >
< xsl:if test ="string-length($DisplayTitle) = 0" >
< a href =" {$SafeLinkUrl} " target =" {$LinkTarget} " title =" {@Title} " >
< xsl:value-of select ="$DisplayTitle" />

</ a >
</ xsl:if >
< xsl:if test ="string-length($DisplayTitle) <= 10" >
< a href =" {$SafeLinkUrl} " target =" {$LinkTarget} " title =" {@Title} " >
< xsl:value-of select ="$DisplayTitle" />

</ a >
</ xsl:if >
< xsl:if test ="string-length($DisplayTitle) > 10" >
< a href =" {$SafeLinkUrl} " target =" {$LinkTarget} " title =" {@Title} " >
< xsl:value-of select ="substring($DisplayTitle,1,9)" />

</ a >
</ xsl:if >
</ td >
< td width ="100px" >
< xsl:value-of select ='substring(@Modified,1,4)' ></ xsl:value-of >
</ td >
< td align ="right" > 回复数量:
< xsl:value-of select ="@ItemChildCount" />
</ td >
</ tr >
</ table >
</ div >
</ xsl:template >