Monday, August 13, 2007

Custom action locations and groupid's

I've been wandering around the internet to find all the locations that you can define to add your custom action at. You see, I want to add a link near the 'Welcom <User>, My Site, My Links' section (aka the global links section). What I found was the following :

Using CustomAction to modify system pages by Chris O' Brien

  • Microsoft.SharePoint.ContentTypeTemplateSettings
  • Microsoft.SharePoint.ContentTypeSettings
  • Microsoft.SharePoint.Administration.ApplicationCreated
  • Office.Server.ServiceProvider.Administration (Shared Services/SSP links)
  • Microsoft.SharePoint.ListEdit.DocumentLibrary
  • Microsoft.SharePoint.Workflows
  • NewFormToolbar
  • DisplayFormToolbar
  • EditFormToolbar
  • Microsoft.SharePoint.StandardMenu (SiteActions menu)
  • Mcrosoft.SharePoint.Create (_layouts/create.aspx - the screen used to specify what you want to create on your site)
  • Microsoft.SharePoint.ListEdit (the screen used to edit the properties of a list item)
  • EditControlBlock (image below)

That's more than Microsoft specified on their page How to: Add Actions to the User Interface. But still I didn't found my answer on how to add a link to the global links section. Then I went looking in the 12/Templates/Controltemplates folder for the usercontrol that renders the 'Welcome <User>' section, named "Welcome.ascx". There I found the following bit :

     <SharePoint:FeatureMenuTemplate runat="server"
         FeatureScope="Site"
         Location="Microsoft.SharePoint.StandardMenu"
         GroupId="PersonalActions"
         id="ID_PersonalActionMenu"
         UseShortId="true"
         >

Now it's the GroupId that interested me.. So I created a feature that looks this (first part being the feature.xml and the second being the elements.xml) :

<Feature 
  Id="AA929AFF-4602-4d7f-A501-B80AC9A4BB52" 
  Title="Add Links to user section"
  Description="Feature that adds a link to Welcome User section"
  Scope="WebApplication" 
  xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="Elements.xml" />
  </ElementManifests>
</Feature>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction 
        Id="0acdbd94-eba8-11db-8314-0800200c9a66"
        GroupId="PersonalActions"
        Location="Microsoft.SharePoint.StandardMenu"
        Sequence="1000"
        Title="View Terms of Use"
        Description="Open the Terms of Use document"
        ImageUrl="_layouts/1033/images/KpiListView.png">
        <UrlAction Url="_layouts/termsofuse.aspx"/>
    </CustomAction>
</Elements>

 

So how does that look in real life I hear you wonder... well like this :

 

Technorati tags: ,

8 comments:

Anonymous said...

Hello!

I was trying to show display name in the welcome control (wssuc:Welcomeid="explitLogout" runat="server" ') in the masterpage...not the domain\login that appears.
Is this possible to be done? How can i do that?!??
Can you please help me??

Thks!
Cris

Robin Meuré said...

Hi Cris,

well apparently the users are not yet imported in SharePoint otherwise the display name (property of AD) is used in the 'welcome' control. If SharePoint is unable to find the display name it automatically uses the domain\username property.

Are you running WSS or MOSS and are the users already added to any sites?

Duncan G said...

Is it possible to show other details (e.g. Department) in this control?

Thanks,
Duncan

Unknown said...

Hi Robin,
How/where from does the Welcome.ascx control get the logged in user detail?.
I am planning to use this user information in a "Hello User_Name" web part.

Thanks
Jagan

Anonymous said...

I'm having trouble getting an image to display next to the link I have created. Please can someone give me some more details about where to place the image and what to put as the image Url in the code?

Thanks

Andy

Jason said...

Cris,

Ensure that the account used to query AD has permission to do so.

http://discoveringsharepoint.blogspot.com/2008/11/displaying-correct-user-names.html

Unknown said...

I want to add a custom link in welcome menu and I read your post but I dont understand where to put the code exactly.
Can any please help me.

Samana said...

Hey,

thanks for your post!

can you tell me please what if I want to hide some menu item from the menu. Lets say i want to hide "My settings". How can I override that action?

BR

-Saman