Adding a custom button into the Umbraco content menu

I needed to add a custom button into the menu bar shown on each tab in the content editor in Umbraco.

Firstly you need to hook onto the page load event within the backoffice via a class implementing IApplicationStartupHandler.

public class CustomButton : IApplicationStartupHandler
{
public CustomButton()
{
umbracoPage.Load += UmbracoPageLoad;
}

private void UmbracoPageLoad(object sender, EventArgs e)
{
}
}

Right so now we have a place where we can manipulate the tab menu. There are a few null reference checks we could do with throwing in but we’re essentially going to run the following. Our button needs to be added to each menu in each tab.

private static void AddButton(umbracoPage page)
{
var tabView = (page.FindControl(“body”)).FindControl(“TabView1”) as TabView;

if (tabView == null) return;

foreach (TabPage panel in tabView.GetPanels())
{
var menuButton = panel.Menu.NewImageButton(1);
menuButton.AlternateText = “My custom button rocks”;
menuButton.ImageUrl = “~/images/cms/myimage.gif”;
menuButton.Click += CustomButtonClicked;
}
}

As this is an image button we can handle the click in the usual webforms way.
Here’s the full implementation:

namespace DetangledDigital.Demo.StartupHandlers
{
using System;
using System.Web;
using System.Web.UI;
using umbraco.BasePages;
using umbraco.interfaces;
using umbraco.presentation.masterpages;
using umbraco.uicontrols;

public class CustomButton : IApplicationStartupHandler
{
public CustomButton()
{
umbracoPage.Load += UmbracoPageLoad;
}

private void UmbracoPageLoad(object sender, EventArgs e)
{
var page = sender as umbracoPage;

if (page == null)
return;

if (!page.Page.Request.Path.ToLower().Contains(“editcontent.aspx”))
return;

AddButton(page);
}

private static void AddButton(umbracoPage page)
{
// Js fix for toolbar, may be required dependant on menu setup.
// page.Page.ClientScript.RegisterClientScriptBlock(GetType(), “cssfixtoolbar”, “<style type=’text/css’>.mceToolbarExternal{left:108px;}</style>”);

var tabView = (page.FindControl(“body”)).FindControl(“TabView1”) as TabView;
if (tabView == null) return;

foreach (TabPage panel in tabView.GetPanels())
{
var menuButton = panel.Menu.NewImageButton(1);
menuButton.AlternateText = “My custom button rocks”;
menuButton.ImageUrl = “~/images/cms/sendToEditor.gif”;
menuButton.Click += CustomButtonClicked;
}
}

private static void CustomButtonClicked(object sender, ImageClickEventArgs e)
{
var nodeId = int.Parse(HttpContext.Current.Request.QueryString[“id”]);

// Do some bits

// Show the user a notification
BasePage.Current.ClientTools.ShowSpeechBubble(BasePage.speechBubbleIcon.success, “Success”, “The content has been sent for approval.”);
}
}
}

Procuring Agile Software Development

Intended Audience Before we get into the depths of this blog post I think it’s important to define what type of procurement I’m talking about and who this approach is appropriate for. Each procurement scenario has it’s own nuences and challenges and one size certainly does not fit all. In this series of blog posts … »

Umbraco V4.x Clearing old document revisions

This script will clear old document revisions ensuring the current revision isn’t removed.

Due to the way the Umbraco schema works if you have one doctype with 10 properties then publish that document 10 times you will have added 100 rows into the cmsPropertyData table and a number of rows into other tables through the CMS.

The costs are in the gaps

Arguing for an end to back offices and target driven approaches, John Seddon outlines theories that could permanently alter management approaches.When I was a young man the term ‘back office’ did not exist. Today it is in common parlance; it is considered axiomatic that back offices are a feature of efficiency; Whitehall extols their virtue; they are springing up all around us. Where did the idea come from? What problem was it designed to solve? Does it solve that problem? Answers to these questions will cause concern to those who have jumped on the back office bandwagon.It began in 1978. Richard Chase, writing in the Harvard Business Review, lamented the failure of service organisations to be as technocratic as manufacturers. His view – and a view still widely shared amongst managers of services – was that the job of management is to optimise the use of resources – get people working all day – and in services that can be difficult because the customer comes in and ‘interrupts’ the workers.Chase proposed that we design services to have front offices, where customers are seen or spoken to over the phone, which then send the customers’ requirements to back offices where now, because the activity has been ‘de-coupled’ from the customer, efficiency can be pursued, resource can be optimised, labour can be sweated.Housing benefits was the first back-office design mandated in local authorities. About eight years ago the Department for Work and Pensions (DWP) sent local authorities a three-box set of manuals which promulgated a front-office/back-office design with associated activity targets. The design created backlogs in back offices all over the country and the DWP ‘help team’ recommended that local authorities buy back-log busting services from the private sector. I labelled them the ‘no help’ team, for that didn’t help; it was the wrong answer, adding cost to cost.As Mark Radford – a housing benefits leader in Swale Borough Council – observed at the time, the problem was not in the back office, it began in the front office. By worrying about seeing people quickly, individual claims became fragmented.Studying the service also revealed that back-office people took a different view of the claimant than the front-office people; a checklist took over from face-to-face understanding.Radford was one of the first public-sector managers to learn the error of working to reduce transaction costs, for the true cost of any service is end-to-end: the total number of transactions it takes for someone to receive a service could be as many as ten transactions. In short, he discovered that complying with DWP guidance only served to create failure demand: demand caused by a failure to do something or do something right for the customer.To compound the error, the Audit Commission then bullied housing benefits managers to share their back offices. A problem shared is, in this case, a problem exacerbated.To further compound the error, we see back offices being outsourced to the private sector, locking in high costs for the long term. Birmingham City Council has, thankfully, woken up to the truth that they are paying their outsource provider, Capita, millions every year for Capita to service failure demand. That’s the good news. The bad news is they don’t know the causes.And these are they: the separation of front and back-offices, the standardisation and specialisation of work, the management of activity and, in general, the obsession with sweating the labour. Add to this the fact that back-office services outsourced to the private sector are contracted on the basis of transaction volumes and you can see that we have monumental train crashes in the making. South West One, the outsourced back-office deal between Somerset, Taunton Dean and IBM, which is now too expensive to get out of, according to the leader in Somerset, is merely a harbinger.If you look at business cases put forward for back offices and sharing or outsourcing the same, you see promises of two types of savings: less-of-a-common-resource (i.e. fewer managers, buildings and so on) and lower costs through cheaper transactions.The first is true, but marginal, and often happens early in the life of a venture, giving encouragement to the notion that it was a good idea; but the second is the big promise and false. Chase was wrong. It is a foolish manager who thinks it is their job to sweat the labour, who believes that costs are in transactions, who believes it is their job is to manage costs. It is the wise manager who learns to manage value, not cost.No back office, no targets, no activity management, but instead a thorough understanding of citizen demand and staff with the wherewithal to deal with it.You can buy John Seddon’s book of case studies – Delivering Public Services That Work Volume 2 – from Triarchy Press.From Localgov.co.ukhttp://m.localgov.co.uk/Article/Default.aspx?id=108344

Dangerous Architects

Have you noticed that developers have a propensity to ‘start again’? I have seen it time and again. A developer picks up a new area of an existing application and then almost immediately declares it as useless, flawed, poorly written, overly complex and that they need to rewrite it. Of course it takes longer than…

Becoming Responsable

Most of us avoid taking personal responsibility for conflict resolution. We often lack the courage to deeply connect with others and we personally avoid confrontation. If we have a disagreement in a business transaction or with a neighbor, we may let a lawyer take care of it. If we have emotional conflict, we may visit a therapist or counselor who we hope will tell us what to do.

The Importance of Feedback

A while ago I found myself working alone on a small application. As it was just me I decided to forego the setup of CI, etc and just get on with developing the app. I used TDD initially and for a time all was well. After a while I gave a demonstration of the app. […]

A Principled Position

I’ve always been rather sceptical about principles. Well hang on, let me back track a little as that statement could read the wrong way… to be more precise, principles I have found documented in teams/organisations. “Having principles” is a good thing, it is in life and it should be in organisations.  Its just that all […]

Maslow may just have had a point …

I’m sure we are all familiar with Maslow’s hierarchy of needs.If i’m being honest i saw this as a theoretical model that had little to do with me for many years.However, as i continue to work with clients on transformational change programmes this beco…

PastThought

I thought I would start my FutureThought blog with a bit of reflection on the past. This is my second (or maybe third) attempt at writing the post…I’ve come to realise that the past, even my short past, has a lot to offer. Firstly a whistle stop tour of my history… My professional development career […]

1 66 67 68 69