使用 jQuery 更改 SharePoint 中的 application.master 页面
我们使用 MOSS 2007 (SharePoint) 作为我们的 Intranet。最近,我们的任务是为我们农场的多家公司提供品牌支持。我们很快意识到应用程序页面(由修改后的 application.master 生成)无法提供多个品牌模板(主题除外)。
我认为正确的解决方法是在应用程序页面上保留默认的 Microsoft 品牌(我们已经在开发中致力于此 - 不对服务器上托管的文件进行修改)。
然而,作为一种快速解决方案,我想我也许可以使用 jQuery 来替换应用程序页面上的一个徽标、一些导航图像和一些颜色。基本上在页面完全呈现之前从品牌 A 到品牌 B。
我的问题是……这个想法有多糟糕?这样做有哪些陷阱?鉴于这只是一个临时解决方案,我应该尝试一下吗?
We use MOSS 2007 (SharePoint) for our intranet. Recently we were tasked with supporting the branding for multiple companies on our farm. We quickly realized that the application pages (produced by a modified application.master) can't serve up multiple branded templates (other than themes).
I think the right fix is to keep the default Microsoft branding on application pages (we were already working on this in dev - no modifications to files hosted on the server).
As a quick fix however, I was thinking that I might be able to use jQuery to replace one logo, a handful of nav images, and a few colors on the application pages. Basically going from Brand A to Brand B before the page is fully rendered.
My question is... how bad is this idea? What are the pitfalls associated with doing this? Given that it is only an interim solution, should I try it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要添加到 Kobi 的答案,您可以使用委托控制功能进行部署。
在
_controltemplates
下放置一个用户控件,如:编写委托控件功能(这里是elements.xml):
包含自定义CSS在
_layouts/custom/app.css
中。To add to Kobi's answer, you can use a delegate control feature for deployment.
Place a user control under
_controltemplates
, such as:Write the delegate control feature (here is elements.xml):
Include custom CSS in
_layouts/custom/app.css
.我认为你的大部分问题都可以通过一个好的 CSS 文件来解决。根据我的经验,这比 javascript 更好,因为它加载速度更快。请记住,SharePoint 会生成大量页面(DOM 方面),因此 jQuery 需要很长时间才能到达
$(document).ready
,甚至在 IE6 上操作过大的 DOM 需要更长的时间这可能需要几秒钟,给人的印象就像网站或服务器速度慢一样。我使用 CSS 对 SharePoint 进行了许多自定义:可能需要一些臭味
!important
,但结果比 javascript 更好。另外,请记住,您可以设置每个站点的 CSS 文件(在设置子站点的母版页的同一页面上) - 这可以用来代替实际为每个品牌创建母版页。
I think most of your problems can be solved with a good CSS file. This is better than javascript, in my experience, since it loads a lot faster. Keep in mind that SharePoint produces heavy pages (DOM wise), so jQuery takes a long time to get to
$(document).ready
, and even longer time to manipulate that over-sized DOM - on IE6 this can take several seconds, giving the same impression as a slow site or server.I've done many customization to SharePoint using CSS: It may take a few smelly
!important
s, but the result is better than javascript.Also, remember that you can set a per-site CSS file (on the same page you set the sub-site's master page) - this can be used instead of actually creating a master page for every brand.