惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

SecWiki News
SecWiki News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
博客园 - 叶小钗
S
SegmentFault 最新的问题
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
腾讯CDC
D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
L
Lohrmann on Cybersecurity
量子位
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
J
Java Code Geeks
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
博客园 - 三生石上(FineUI控件)
Attack and Defense Labs
Attack and Defense Labs
AI
AI
The Cloudflare Blog
T
Tailwind CSS Blog
S
Schneier on Security
爱范儿
爱范儿
PCI Perspectives
PCI Perspectives
Stack Overflow Blog
Stack Overflow Blog
S
Secure Thoughts
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
The Exploit Database - CXSecurity.com
博客园 - 【当耐特】
V2EX - 技术
V2EX - 技术
S
Securelist
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
Help Net Security
Help Net Security
C
Cisco Blogs
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
K
Kaspersky official blog
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Simon Willison's Weblog
Simon Willison's Weblog

博客园 - Francis Liang

Windows Azure存储容器私有,公共容器,公共Blob的区别 关于Windows Azure 地缘组(Affinity Groups) 使用Windows Azure创建和发布ASP.NET应用程序 创建并使用Windows Azure虚拟机模板 Windows Azure 设置虚拟机静态外网IP地址 Windows Azure 配置多个站点的虚拟网络连接 Windows Azure 虚拟网络配置(Site to Site) Windows Azure 虚拟网络配置(Point to Site) Microsoft Azure云计算第一步—试用帐户申请 拥抱云计算 《Microsoft Office SharePoint Server 2007 Best Practices》书评 [.NET Active Directory开发]根据NativeGuid获取DirectoryEntry实例 IISRESET命令功能新发现 动态改变ASP.net页面标题和动态指定页面样式表 Biztalk Server 2006安装配置 Web开发中对元素样式使用过滤器以增强其可视化效果 使用DIME协议上传文件 使用证书来做RSA非对称式加密 使用MSAgent代替传统的MessageBox提示来增用客户端用户体验
修改MOSS2007内容查询部件实现自定义格式显示
Francis Liang · 2007-11-19 · via 博客园 - Francis Liang

很抱歉,本来是有截图的,可以让过程看得更清楚些,但可能由于机器的原因,图片始终无法上传.所以只能写文字版了!
    在
Office SharePoint Server 2007中的内容查询Web Part只支持单个列进行显示(默认为标题列),即使将列表中的列设置为富文本格式在内容查询Web Part中也显示为不带样式的文本。下面的方法将实现在内容查询Web Part中显示我们添加的列并使用样式。

1.       为通知列表添加自定义列

在本例中我们为通知添加的自定义栏名称为“显示标题”,多行文本;富文本类型。

*关键要点:如果自定义栏的名称为非英文,为了避免SPField.InternalName属性被编码需要在创建时先用英文名称代替,并须牢记该名称,我们在后面的修改均用该英文名称。创建完成后我们再将栏的名称修改为中文,此时SPField.InternalName属性并不会被修改,而维持原命名的英文名称.

2.       将内容查询WebPart导出并修改

在页面中加入一个内容查询WebPart,将其查询设置为我们刚才所修改的通知列表。通过其上下文菜单将其导出成文件。

我们用记事本打开保存到本地磁盘的.webpart文件,找到<property name="CommonViewFields" />,将其修改为:

<property name="CommonViewFields" type="string">CustomTitle,RichText;</property>其中的CustomTitle为我们上一步中添加的自定义栏的名称(第一次输入的英文名称),RichText为该栏目的类型,保存该修改。3.       修改XSL文件

我们用SharePoint Designer打开网站(http://moss:8000),在文件夹列表中找到\Style Library\XSL Style Sheets目录,将会看到ItemStyle.xslContentQueryMain.xslSummaryLinkMain.xsl三个文件,我们将会对其进行修改

Ø                                              打开ContentQueryMain.xsl找到<xsl:template name="OuterTemplate.GetTitle">将该template定义复制,将复本的名称更改为OuterTemplate.GetCustomTitle,相应的修改如下:

<xsl:template name="OuterTemplate.GetCustomTitle">

        <xsl:param name="CustomTitle" select="@CustomTitle"/>

        <xsl:param name="UrlColumnName"/>

        <xsl:if test="string-length($CustomTitle) != 0">

            <xsl:value-of select="$CustomTitle"/>

        </xsl:if>

        <xsl:if test="string-length($CustomTitle) = 0">

            <xsl:if test="$UseCopyUtil = 'True'">

                <xsl:value-of select="$BlankTitle" />

            </xsl:if>

            <xsl:if test="$UseCopyUtil != 'True'">

                <xsl:call-template name="OuterTemplate.GetPageNameFromUrl">

                    <xsl:with-param name="UrlColumnName" select="$UrlColumnName"/>

                </xsl:call-template>

            </xsl:if>

        </xsl:if>

</xsl:template>

保存修改。

Ø   打开SummaryLinkMain.xsl文件找到<xsl:template name="OuterTemplate.GetTitle">将该template复制,将复本的名称更改为GetCustomTitle,相应的修改如下:

    <xsl:template name="OuterTemplate.GetCustomTitle">

        <xsl:param name="CustomTitle" select="@CustomTitle"/>

        <xsl:value-of select="$CustomTitle"/>

</xsl:template>

保存修改。

Ø  打开ItemStyle.xsl文件,我们需要在该文件中加入一个样式定义

找到<xsl:template name="Default" match="*" 将这个名为Defaulttemplate复制一份,将name属性修改为AnnouceListmatch属性修改为Row[@Style=’AnnouceList’]。并在variable中加入在上一步骤中加入的自定义栏的定义,并命名为CustomTitle(见下文示例)。

修改后的template定义为:

        <xsl:template name="AnnouceList" match="Row[@Style= AnnouceList]" 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="SafeImageUrl">

            <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">

                <xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>

            </xsl:call-template>

        </xsl:variable>

        <xsl:variable name="CustomTitle">

            <xsl:call-template name="OuterTemplate.GetCustomTitle">

                <xsl:with-param name="Title" select="@CustomTitle"/>

                <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">

            <xsl:if test="string-length($SafeImageUrl) != 0">

                <div class="image-area-left">

                    <a href="{$SafeLinkUrl}" target="{$LinkTarget}">

                        <img class="image" src="{$SafeImageUrl}" alt="{@ImageUrlAltText}" />

                    </a>

                </div>

            </xsl:if>

            <div class="link-item">

            <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>    

            <table style="width:100%">

                     <tr>

                               <td style="width:100%" class="itemlink-item">

                                        <a href="{$SafeLinkUrl}" mce_href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}">

                                                 <xsl:value-of select="$CustomTitle" disable-output-escaping = "yes"/>

                                        </a>

                               </td>

                     </tr>

            </table>

             </div>

        </div>

</xsl:template>

 保存修改。

 4.       导入前面步骤修改的.webPart文件

打开网站集站点管理-web部件,将修改的.webpart文件上传,将该webpart名称设置为“公告栏”.

5.       将新加入的webpart重新加入页面,修改其webpart属性。

将项目样式设置为我们在上一步的XSL定义中的样式"AnnouceList"。点击“确定”按钮。