Skip to main content

Cloud

Personalize Your Publishing Console

Wouldn’t it be nice in SharePoint 2007 if we could put our own buttons into the publishing menu?We can…it just takes a few steps.The steps taken are determined by the master page that is used.If you are using default.master, you will need to create a delegate control.There are plenty of examples for adding your own delegate control, so I will not go into that.My delegate control was copied from the PublishingMenu.ascx.The control we want to change within the publishing console is called the QuickAccessMenu.I wanted to start a custom workflow that was part of an approval process and I wanted users to enter comments when the workflow was started.I created my own check in page that the button redirects the users to when it is clicked. My check in page requires comments and starts a workflow.To do this I created my own QuickAccessMenu control that instantiates the MS QuickAccessMenu.I then use the following code to change the functionality of the Submit for Review button:

 

public override void RenderControl(HtmlTextWriter writer)

{

int location = GetControlLocation();

if (location > 0)

{

Control pub = menu.FindControl(“qaApprovePublish”);

if (pub != null && !SPContext.Current.Web.CurrentUser.IsSiteAdmin)

pub.Visible = false;

 

Control ctrl = (Control)menu.Controls[location];

PublishingButton button = (PublishingButton)ctrl.Controls[0];

button.DisplayText = “Start Custom Workflow”;

string url = string.Format(“{2}/_layouts/CustomLayouts/CustomCheckin.aspx?List={0}&FileName={1}&Publish=true&Source={1}&ListItemID={3}”, SPContext.Current.ListItem.ParentList.ID.ToString(“B”), SPContext.Current.Item[“FileRef”].ToString(), SPContext.Current.Web.Url, SPContext.Current.ListItem.ID);

button.ClientOnClickScript = string.Format(“location.href='{0}'”, url);

}

 

base.RenderControl(writer);

}

 

The code above searched for a control called “qaPublish” and changes the some properties on the button before rendering. When the control is rendered it looks like the following image:

You can add new buttons to the control as well. The button type is PublishingButton. This will allow you to start workflows from these buttons or anything else you want.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.