All About Microsoft SharePoint

March 12, 2008

Send To->Email a Link doesn’t work

Filed under: Document library — calvin998 @ 3:04 pm
Tags:

In SharePoint 2007’s Document library, the Send To->Email a Link context menu will open your local email client and put the link of that document in the email body. However, it seems URL encode the whole URL, instead of just the relative path.  So the URL will end up like this:

 http://subdomain%2Ecompany%2Ecom/Documents/folder/subfolder/My%20File.doc

Basically, the dot (.) in the domain name is also URL encoded (%2E). If you copy and paste it to IE it will still load, but clicking it from Outlook doesn’t work.

To fix it, open CORE.js from  \12\TEMPLATE\LAYOUTS\1033, fine this line:

 fileUrl=escapeProperly(httpRootWithSlash.substr(0, slashLoc))+currentItemUrl;

and replace it with this:

fileUrl=httpRootWithSlash.substr(0, slashLoc)+currentItemUrl;

I found OWS.js (in same folder) also have this. But changing CORE.js alone will fix it. I don’t know what’s the difference between these 2 files.

September 28, 2007

Remove a menu group (or menu) from toolbar

Filed under: Navigation — calvin998 @ 3:19 pm
Tags:

To remove a whole menu group, this link has the answer:

http://blogs.msdn.com/dipper/archive/2006/10/05/How-to-Remove-or-hiding-items-in-List-toolbar-in-Sharepoint-Server-2007.aspx

To summarize it (in my understanding and language):

In \12\TEMPLATE\CONTROLTEMPLATES there are many templates. By just dropping a new template file (file name doesn’t seem to matter) with

<SharePoint:RenderingTemplate ID=”DocumentLibraryViewToolBar” runat=”server”>

it will override the default template defined in DefaultTemplates.ascx. So even DefaultTemplates.ascx still has that menu groups, it will be hidden on UI. IISRESET or application pool need to be recycled before this takes effect.

However, this \12\TEMPLATE\CONTROLTEMPLATES folder is shared by all sites installed on same server. What if other sites don’t want to hide that menu group? Here is my trick: make a copy of that “ControlTemplates” folder and put the customized file there. Then go to InetMgr and change the virtual directory path to point to the new folder for those applications that want this change.

This is the file to hide “New” menu group in Doc Lib page toolbar:

==================================

<%@ Control Language=”C#” AutoEventWireup=”false” %>
<%@Assembly Name=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@Register TagPrefix=”SharePoint” Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” namespace=”Microsoft.SharePoint.WebControls”%>
<%@Register TagPrefix=”SPHttpUtility” Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” namespace=”Microsoft.SharePoint.Utilities”%>
<%@ Register TagPrefix=”wssuc” TagName=”ToolBar” src=”~/_controltemplates/ToolBar.ascx” %>
<%@ Register TagPrefix=”wssuc” TagName=”ToolBarButton” src=”~/_controltemplates/ToolBarButton.ascx” %>

<SharePoint:RenderingTemplate ID=”DocumentLibraryViewToolBar” runat=”server”>
<Template>
<wssuc:ToolBar CssClass=”ms-menutoolbar” EnableViewState=”false” id=”toolBarTbl” ButtonSeparator=”<img src=’/_layouts/images/blank.gif’ alt=”>” RightButtonSeparator=” ” runat=”server”>
<Template_Buttons>
<SharePoint:UploadMenu AccessKey=”<%$Resources:wss,tb_UploadMenu_AK%>” runat=”server”/>
<SharePoint:ActionsMenu AccessKey=”<%$Resources:wss,tb_ActionsMenu_AK%>” runat=”server”/>
<SharePoint:SettingsMenu AccessKey=”<%$Resources:wss,tb_SettingsMenu_AK%>” runat=”server”/>
</Template_Buttons>
<Template_RightButtons>
<SharePoint:PagingButton runat=”server”/>
<SharePoint:ListViewSelector runat=”server”/>
</Template_RightButtons>
</wssuc:ToolBar>
</Template>
</SharePoint:RenderingTemplate>

================================

When it comes to removing a particular menu from a menu group, things didn’t work as expected. You are supposed to do that through a Feature and use <HideCustomAction> to hide a particular menu. There is no where you can get a complete list of IDs of all the menu items. I tried this:

<HideCustomAction>
GroupId = “ActionsMenu”
HideActionId = “ExportToSpreadsheet”
Id = “HideExportToSpreadSheetMenu”
Location = “Microsoft.SharePoint.StandardMenu”>
</HideCustomAction>

But it doesn’t work. I tried a few other combinations of Export To Spreadsheet and none of worked. Google search only returns similar failed attempts. (This page gives you the group IDs).

My workaround is to directly edit DefaultTemplates.ascx file in ControlTemplates folder. Then it’s permanently gone. Backup the file before you make change. Follow aforementioned trick if other sites in same server don’t want the change.

July 23, 2007

Publish a Major Version - events

Filed under: Events — calvin998 @ 7:11 pm
Tags: , ,

Publish a Major Version: this menu is only available when file is in a checked-in status. If it’s already checked out, it can only be checked in. When action is taken, ItemCheckedIn event is not called. Instead, ItemUpdated is called. However, both BeforeProperties.ChangedProperties and AfterProperties.ChangedProperties contains zero information so you can’t tell from ItemUpdated event if this is a “publish” action.

The version # will be automatically bumped to next major version #.

Unpublish this version: same as above, it’s also only available for checked-in status. The version # will be rolled back and ItemUpdated event will be called. ItemCheckedIn is not called (obviously).

If one want to handle these 2 menu actions, seems ItemUpdated event is the only entrance. However many other actions will also trigger ItemUpdated event.

If you want to remove these 2 menus,  edit core.js under \12\TEMPLATE\LAYOUTS\1033\ folder.  I commented out a section in AddCheckinCheckoutMenuItem function to hide the Unpublish menu. I did that because for unknown reason it would cause “Access Denied” error when someone does that after we customized the security.

Blog at WordPress.com.