Laws of CRM and telephony projects Last updated:30 September 2011

Simon’s first law – Comms rooms

One or more of the following will apply

  • There will be no room in the comms room for the new server. Resolving this will necessitate anything up to and including an extension to the building.
  • There will be insufficient power supplies
  • There will be no spare ethernet ports

Note that these rules apply regardless of how recently a comms room has been built.

Simon’s second law – Address formats

No matter how unlikely it seems at the outset, there will be an intense discussion about addresses at some point, normally involving postcodes. This may well extend beyond intense, into heated.

Simon’s third law – head scratching

At some point more than three people will be observered clustered around the same screen with slightly vexed expressions on their faces.

Simon’s fourth law – telephony testing

You will, at some point, have your desk phone to one ear, and your mobile to the other ear, talking to yourself. It’s inevitable. Don’t fight it.

Simon’s theorem on development gurus

In normal circumstances, on any given development project, there’s someone who can fix anything. It may take you a while to work out who he/she is, and even longer to get his time. Slightly more than half of these people are called Dave.

Corollary to the theorem

If no such person exists, you’re in trouble.

Awful geeky joke… Last updated:30 September 2011

There are 10 types of people in the world. Those who understand binary, and those who don’t.

Quite concerned that I find this funny…

Cufon not working in Opera 11 Last updated:10 July 2011

Latest bizarre oddity.

By chance I spotted that Cufon wasn’t working on some pages on my site in Opera 11. Turns out Opera doesn’t like empty stylesheets – these pages had links that I hadn’t removed to a now defunct stylesheet. Removed the dead link and everything works again. Nothing in the stylesheet referred to anything to do with the Cufon text, but it still failed….

WordPress wrapping shortcodes with p tags Last updated:15 June 2011

Been struggling over the last day or so to stop WordPress wrapping p tags around a shortcode. I’m using Arnan de Gans Events plugin on a WordPress site for a client. One of the pages just includes this shortcode:

[events_show]

This shows a list of events. I’ve configured the plugin so each event is in its own div. And it all works fine, except WordPress insists on wrapping the whole thing in a couple of p tags, making the code invalid, producing this:

<p><div class="event>.........</div></p>

Irritating. The WP shortcode API site says “wpautop recognizes shortcode syntax and will attempt not to wrap p or br tags around shortcodes that stand alone on a line by themselves”. Nooooo.

I finally solved this by adding the following to my functions.php file:

function simonbattersby_shortcode_format($content){
$content = preg_replace('/(<p>)\s*(<div)/','<div',$content);
$content =  preg_replace('/(<\/div>)\s*(<\/p>)/', '</div>', $content);
return $content;
}

add_filter('the_content','simonbattersby_shortcode_format',11);

Points to note – the filter needs to be set with priority 11 (or higher) because otherwise the shortcode won’t have produced its output, and it’ll have no effect. All the preg_replace lines are doing is looking for a <p> tag followed by <div>, with any number of whitespaces between them, and replacing with just a <div> tag. Brute force, inelegant, but it works, and I couldn’t find any other way….

Preventing doubleclick firing two clicks with jQuery Last updated:14 November 2010

A user of my wife’s workshop page reported that they couldn’t click to expand a div – when they did it opened and then immediately closed again. Experimentation showed that in fact they were double clicking rather than single clicking – registering two click events in fact. My original code was:

$('h3 span a').click(function() {
    $(this).parent().parent().siblings(".event_hidden").slideToggle();
    return false;
});

When I started thinking about it, I couldn’t immediately see how to separate the two events – after all, a doubleclick is just two clicks, isn’t it? Fortunately jQuery provides an easy solution by using the event properties:

$('h3 span a').click(function(event) {
    if(event.detail==1){//activate on first click only to avoid hiding again on double clicks
        $(this).parent().parent().siblings(".event_hidden").slideToggle();
    }
    return false;
});

Edit 14 November 2010 Actually, problem not quite solved, since I found that IE8 and under (I don’t know about IE9) don’t recognise event.detail, and hence the code above prevents the slideToggle working entirely. Fortunately, neither does the doubleclick problem seem to affect these browsers, and hence I amended my code to:

$('h3 span a').click(function(event) {
    if(!event.detail || event.detail==1){//activate on first click only to avoid hiding again on double clicks
        $(this).parent().parent().siblings(".event_hidden").slideToggle();
    }
    return false;
});