SharePoint 2010 WebPart个性化布局

时间:2011-08-19 22:27:16

标签: sharepoint sharepoint-2010 web-parts ribbon webpartpage

我在Intranet上有一个主页。它有15个以上的网站部分(新闻,天气等)我希望允许用户通过移动webparts或删除它们来自定义页面。目前我不让他们在顶部看到功能区,因此他们无法访问“编辑页面”按钮。我已经从功能区中取出了它

<a unselectable="on" href="javascript:;" onclick="return false;" class="ms-cui-ctl-large" aria-describedby="Ribbon.WebPartPage.Edit.Edit.Menu.Actions.Edit_ToolTip" mscui:controltype="Button" role="button" style="height: auto;" id="Ribbon.WebPartPage.Edit.Edit-SelectedItem">
<span unselectable="on" class="ms-cui-ctl-largeIconContainer">
    <span unselectable="on" class=" ms-cui-img-32by32 ms-cui-img-cont-float">
      <img unselectable="on" alt="" src="/_layouts/1033/images/formatmap32x32.png" style="top: -160px; left: -96px;">
    </span>
</span>
<span unselectable="on" class="ms-cui-ctl-largelabel" style="height: auto;">Edit<span unselectable="on"> 
</span>Page</span>
</a>

不幸的是它不起作用。有什么想法吗?

我也将使用“停止编辑”按钮执行相同操作。

2 个答案:

答案 0 :(得分:0)

根据这篇文章:http://artykul8.com/2011/03/useful-sharepoint-shortcuts/ 诀窍是使用MSOLayout_ToggleLayoutMode(); javascript函数。

根据该页面中的评论,在SP2010中,只有当您在页面中已有Web部件时,该javascript功能才可用。 我观察到的行为与此不同,因为对我来说,此功能仅在页面处于编辑模式时才起作用(即使页面没有添加Web部件,它也能正常工作)。 / p>

我能够找到定义该函数的javascript文件,即ie55up.js。您可以通过执行以下操作将其加载到母版页中:

<SharePoint:ScriptLink language="javascript" name="ie55up.js" OnDemand="false" runat="server" />

有关如何构建使用该javascript函数的Web控件的信息,请参阅此处:http://www.codeproject.com/KB/sharepoint/SwitchWPMode.aspx

希望这有帮助

答案 1 :(得分:0)

我终于找到了这个问题的答案。确定JS调用后,这非常简单。我相信这应该是一个仅限webpart的页面。

通过Javascript调用将页面置于个性化的编辑模式中:

ChangeLayoutMode(true); // how simple is that??

通过Javascript调用停止编辑页面:

MSOLayout_ToggleLayoutMode(); // same as given in the other post

我认为“停止”编辑模式对于所有页面都是相同的,无论它是个性化页面,所有webparts页面等等。