使用jQuery更改SharePoint中的application.master页面
-
05-07-2019 - |
题
我们将MOSS 2007(SharePoint)用于我们的Intranet。最近,我们的任务是为我们农场的多家公司提供品牌支持。我们很快意识到应用程序页面(由经过修改的application.master生成)无法提供多个品牌模板(主题除外)。
我认为正确的解决方法是在应用程序页面上保留默认的Microsoft品牌(我们已经开发了这个 - 不修改服务器上托管的文件)。
然而,作为一个快速解决方案,我想我可以使用jQuery替换应用程序页面上的一个徽标,少量导航图像和一些颜色。在页面完全呈现之前,基本上从品牌A到品牌B.
我的问题是......这个想法有多糟糕?这样做有什么陷阱?鉴于它只是一个临时解决方案,我应该尝试吗?
解决方案
我认为大多数问题都可以通过一个好的CSS文件来解决。根据我的经验,这比javascript更好,因为它加载速度更快。请记住,SharePoint会生成大量页面(明智的DOM),因此jQuery需要很长时间才能到达 $(document).ready
,甚至需要更长的时间来操作那个过大的DOM - 在IE6上这可能需要几秒钟,给人的印象与慢速网站或服务器相同
我使用CSS对SharePoint进行了很多自定义:可能需要一些臭!important
,但结果比javascript更好。
此外,请记住,您可以设置每个站点的CSS文件(在您设置子站点的母版页的同一页面上) - 这可以用来代替为每个品牌实际创建母版页。
其他提示
添加到 Kobi的回答,您可以使用委托控制功能进行部署。
将用户控件放在 _controltemplates
下,例如:
<%@ Control Language="C#" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %>
<SharePoint:CssRegistration name="/_layouts/custom/app.css" runat="server"/>
编写委托控制功能(此处为elements.xml):
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control ControlSrc="~/_ControlTemplates/CustomBranding.ascx"
Id="AdditionalPageHead" Sequence="1" />
</Elements>
在 _layouts / custom / app.css
中加入自定义CSS。