CKEditor and spellcheck in Drupal

So one of the things you find with the English langauge is a lot of spell checkers defaulting to American English and not British English. This hook allows you to set the spell checker in CKEditor to default to British rather than American which I find is one of those little touches which can make the content editing workflow appear a lot more user friendly.

/**
* Implements hook_wysiwyg_editor_settings_alter().
*
* Force language settings to British English.
*/

function MODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
  if (
$context['profile']->editor == 'ckeditor') {
   
$settings['language'] = 'en-gb';    // UI language
   
$settings['scayt_sLang'] = 'en_GB'; // Spell Check As You Type language
   
$settings['wsc_lang'] = 'en_GB';    // Check Spelling button language
 
}
}

 

Thanks to longwave on Drupal.org 

Precedent are looking for Drupal developers

Precedent the digital agency I work for are currently looking for Drupal people to join our team in Worthing. We have some very exciting projects coming up over the next year which is allowing us to expand our current team of 5 Drupal developers. We are not looking for a specific sets of skills at a certain level. What is most important is the person, someone willing to come on board and get stuck into some Drupal projects.

A bit about Precedent;

  • 6 offices - London, Worthing, Cardiff, Edinburgh and Perth and Melbourne down under.
  • Approx. 80 people (design, development, sys admin, consulants, pm's and testers)
  • Great clients - Parkinson's UK, The Wildlife Trusts, MS Society and British Council are just a few of our clients using Drupal
  • Sector focused - Because we focus in sectors we have built up a great reputation meaning that we get some of the best work in those sectors
  • Third sector, Education, Health, Finance and Memberships

Precedent and Drupal

We are investing in the groth and development of our existing Drupal team but are also looking to grow in terms of numbers so want to add some new faces to the mix. We have set standards and practices, many of which follow the Drupal communities set standards, but don't stop there we are always trying to tweak our workflow to get it perfect and use the latest technologies such as Chef and Vagrant to keep all servers up to date. The main thing is that developers, junior to senior, get a fair say in how we work with Drupal. For example we use Git Flow for our git workflow but if you know something better suggest it, we are always open for discussion, in fact our whole current process was put together by the developers.

Why Worthing?

Worthing may seem like an odd choice of location for Precedent, there is a long story about how we came to be part of Precedent which I won't bore you with. But we have become a tech power house in the company with Drupal and hosting both heavily focused here has helped us push our overall Drupal offering forward to include high performance hosting. We are an extension of our London office so you would be involved in Drupal projects from across the company and will be able to visit the London office for client meetings etc. but with the ability to work from the south coast, within easy commuting distance from Brighton.

Sound interesting?

If any of this interests you then get in touch with me via email (adam.elleston@precedent.co.uk) or twitter (@adamelleston). Most importantly don't feel like you have to have an interview straight off if you just want a chat over a tea or coffee.

Sublime 2 text manipulation tricks

I found this great post that helps point out some of the keybopard shortcuts for when you want to play about with text in Sublime.

The best new one for me was ctrl + / for the toggling of comments.

http://whiletruecode.com/post/7-handy-text-manipulation-tricks-sublime-t...

Sublime text 2

So I have been using Sublime text 2 as my text editor of choice for a year now and can't find anything wrong with it. In fact I might even go as far as saying its the perfect editor (for me at least). Being able to set it up really quickly with trimming trailing white space from lines, adding a unix line ending, using 2 spaces as a tab as well as adding a horizontal ruler at 80 characters in for watching line length make it a great tool for Drupal development. I expect most people will play about with their settings to get them just right I know I did. So as I was going to write a post about how I got it setup but thought I would google first and found this post which is identical to how I went about setting it up.

http://realityloop.com/blog/2012/08/09/drupal-development-using-sublime-...

Subsites in Drupal a la BBC style

Project requirements

The site needs to house a number of different sites. Each site can be based off the same theme but want certain control over theme options per site, such as link, text and background colours.

Alternative solutions

There are a wide range of options availible such as using the Domain access module (http://drupal.org/project/domain) or the Subdomain module (http://drupal.org/project/subdomain) however these are suited to sites wanting different domains or sub domains. What we want is something like the following sites all with their own content and different visual style

  • example.com
  • example.com/news
  • example.com/sport

1. Installing the modules

First thing first here so lets download all the required modules.

2. Getting our delta on

Now you have all the above install you will need to create a new delta. A delta is basically a snapshot of you theme that can then be used later on.

Head to admin/appearance/delta and get yourself familiar. We want to click "Add" and give your delta a title and description.

Now the next bit is where it gettings a little bit more interesting. You now have to choose the theme you want to use, yes thats right you could have different organic groups using completely different themes as well as them all using the same theme with different settings. But for this example we just want to use Bartik for everything so select that.

Again another potentially interesting option is setting a parent template (delta). As if this wasn't powerful enough, you can stack them! But again lets leave this as none.

So the final option we also want to leave as "Only override different values"

Then hit the magical save button.

3. Configuration is a go

Now you have a delta you need to configure it. So lets do that. Click configure and you can see what you can do with Bartik.

I won't include a screenshot here but as you can see on your site you have complete control over Bartiks theme options including colours. So edit away and come back here when you ready to put it into action

4. Tying up loose ends

So lets put that delta into use. Create an organic group node on the site then head over to context admin page http://portalmk2.local:8080/#overlay=admin/structure/context

Here we want to add a new context, so give it a Name, tag (I use delta so I can group my delta contexts together), description then add the "OG -grou node context" as a condition and select the Organic Group you want this context to be active on. Then in the reactions you want to choose "Delta" and select which delta you want to run on this context.

5. Review, repeat, refine

Now its a case of viewing that organic group and seeing your delta take effect. This is where you will want to really think about when it comes to your theme you are going to build and what sort of settings do you want to capture in the theme, as they are all configurable per delta now. Could it be that each site wants a different logo, site title, strapline/slogan etc.

You might also find that after experimenting with this that you might not want to use Organic groups, which is fine as you can trigger deltas on any context so it could be URL, menu, node type or just about anything.

​Conclusion​

I think the key here is that when doing this you need to find the right balance between using different delta and different themes together. For example on my new site that I am working on I want each section of the site to have a different style, in most cases its just colour so I can change colour per delta using my base theme. However there is 1 section and maybe more in the future that warrent a new theme, again I can change theme using contexts and delta. It's just something to think about plan for.

New site coming soon

This site was setup just after Drupal 7 launched in January 2011 and was going to be the base of my site. I have since tried to find the time to do this to many times. However now by putting this post up I am forcing myself into a corner, no change to back out now.

The new site will be a Drupal 7 theme based on Twitter Bootstrap. Previously I have attempted to design from the ground up myself but not found the time (let alone the skill) to finish this off. I love the idea of using a well thought out framework and I am finding that Bootstrap is just that.

More to come soon

Custom aliases with arguments in Linux

Nice and short post about creating custom aliases that can take parameters. Just a note that this example is based on my dev virtual machine and uses commands from Drush and Quickstart

So why create an alias

On my dev virtual machine I have Drush and Quickstart installed so I can run the following code to create a new drupal site drush qc --domain=mysite.local --dbuser=root --dbpassword-supersecret Now that is fine but having to enter all of that is bit of a pain so I want to just pass the --domain as that is all that changes between the sites. So I came up with putting the following in my .bashrc file.

You can locate your .bashrc file by running cd ~/.bashrc so edit it and put the following code in.

 

drushqc() {
    drush qc --domain=$1 --dbuser=root --dbpassword=BuoWKwPUw9Swys50qyWu
}
alias buildsite=drushqc

 

Once that is in your aliases file run the following command "source .bashrc" and that will reload your aliases file so the new one will take effect. So to test it just run buildsite --domain=test.local.

Google maps KML not playing nice

If you have or are planning on using custom layers of data in KML files over a Google map then you may want to note this down.

By default the layer will recalculate the centre of the map and the zoom level based on the data in the KML. For me on a recent project this was an issue as the user was placing a marker to centre the map, setting a zoom level per map and adding a KML file to each map. But if their KML file only included data for 1 half of their reserve then  the user would be presented with a map defaulting to showing half of the location rather then the optimal zoom level set in the CMS.

The solution is about as simple as they come.

When setting the custom KML file pass this setting after the filename to force it to show some respect for your existing map configuration.

var customKML = new google.maps.KmlLayer('my-kml-file.kml', {preserveViewport:true});

 

Theming CCK Fieldgroups in Drupal 6

If you ever have any trouble theming fieldgroups in Drupal 6 here is a list of steps to take to get it working

  1. Copy fieldgroup-simple.tpl.php from /$your-module-path/cck/fieldgroup/fieldgroup-simple.tpl.php to /$your-theme-path/fieldgroup-simple.tpl.php
  2. Edit the display of your content type (admin/content/node-type/$node-type-name/display)
  3. Check that the fieldgroups you want to theme are set to simple and not fieldseT

From here on all fieldgroups set to simple display will use this file as its template, if however you want a more specific template for a certain fieldgroup you can now duplicate your fieldgroup-simple.tpl.php and use the following pattern.

fieldgroup-simple-group_my_fields.tpl.php where group_my_fields is the machine name of my fieldgroup

More details of the naming conventions can be found in the modules template preprocess

What is Drupal?

So recently Dries Buytaert (Drupal founder) asked the community "What is Drupal?" and wanted short replies to feature in his DrupalCon keynote at Chicago.
Having spent the last 3 years working with Drupal from version 5 to 6 and now starting to get stuck in with 7 I thought I would have a go at putting down what I think Drupal is. So I put down the following from my experiance as a developer

Drupal is the Swiss army Knife of content management systems. Lots of sharp edges to hurt yourself on but lots of uses and great once you know how to use it.

For those developers that have not worked with Drupal the part about hurting yourself due to the learning curve is sadly true, however I don't regret learning drupal and feel that going through the learning curve was worth it.
I then got an email from Dries asking to feature my quote during his keynote, which was a shock as there have been (at the time of writing this post) 256 comments, so I managed to be one of the lucky few. Sadly I won't be at DrupalCon Chicago however I will be at London later in the year so hope to see some great talks then.

Pages

Subscribe to

Like what you see

You can of course always follow me on twitter to get regular updates