Skip to main content

Working with Drupal

Drupal is an open source Content Management System (CMS) built in PHP. It is used by a wide variety of websites from large corporates through to smaller startups. Drupal is hugely flexible which is what makes it such a great framework around which to build almost any type of website. At ComputerMinds we are a Drupal only development house so Drupal is all we do, all day, every day. To find out more about Drupal and how it can work for you have a look at some of our Drupal articles below and feel free to explore our site further to see how ComputerMinds might be able to help you realise your web goals.

Read some of our articles about Drupal

Drupal image assist force a default alt tag

8th Mar 2008

We make heavy use of the Drupal image assist module (or img_assist as its known) - but find that its handling of empty alt tags is quite poor. The problem being that if when inserting the image the user does not specify a caption or description then the alt (and title) attributes are both empty.

This is clearly not ideal on a modern standards compliant site - luckily the solution to the image assist alt tag problem is a little theme override.


function phptemplate_image_display($node, $label, $url, $attributes) {
  if (!$node->title){
    $node_temp = node_load($node->nid);
    $node->title=$node_temp->title;
  }
  return theme('image', $url, $node->title, $node->title...
Read more

Multilingual views in Drupal when using i18n module

1st Mar 2008

Building multilingual sites in Drupal using the i18n module always throws up a few fun problems to be solved. One of the most awkward being views.

The i18n views integration module does an excellent job of allowing you to return only nodes matching a particular language, but it doesn't help when it comes to translating the view itself - and more importantly allowing a view to site nicely into multiple positions in the menu (one per language).

The solution is to use the excellent insert view module (http://drupal.org/project/insert_view - you can use this guide to get the module and...

Read more

Drupal 6 is released - hoooooray!!

13th Feb 2008

Well, it's finally happened - the brand spanking new Drupal 6 has been released into the wild. We have been playing a lot with Drupal 6 and getting ourselves quite excited (finally drupal_execute has decent return values, and the menu system feels a bit less 'brutal'). However, while we would love to start building client sites on it there is one major omission - the views module.

Suffice to say there have been many discussions about the core-worthyness of the views module, so I am not about to start another one here! Instead I'll just say a HUGE thank you...

Read more

Drupal themeing : Adding active class to the Drupal primary links

29th Jan 2008

This little snippet lives in your phptemplate_variables function and will set a useful 'active' class alongside the not so useful menuid-active class which Drupal assigns to the active primary links


foreach($vars['primary_links'] as $key=>$link){
   if (strpos($key,'-active')){
      $vars['primary_links'][$key]['attributes']['class']='active';
   }
}
Read more

Drupal 5.6 bug affects prevents saving of HTML filter settings

26th Jan 2008

Just flagging this as a bit of an issue - it appears there is fairly serious bug in the version of the filter module provided in Drupal 5.6 which prevents you from saving changes to the allowed HTML tags

A patch is available on drupal.org but it's quite well hidden! Post number 7 in this thread contains a working patch http://drupal.org/node/208700

An alternative solution is to download the 5.x HEAD http://drupal.org/drupal-5.x-dev) and take the version of the filter module from there

UPDATE This has now been fixed with the release of Drupal 5.7

Read more

Force the user to select a leaf item in the Drupal taxonomy

21st Jan 2008

Its a tricky Drupal taxonomy problem this one, imagine you have just set up your taxonomy to represent types of web sites:

    Drupal based Sites

  • Drupal based ecommerce
  • Standard CMS site
  • Social Networking Site
   <ul>Joomla based Sites
      <li>Simple one page site</li>
   </ul>

You set up your node type 'site', and set the vocabulary to apply to it. You create your first site and pop it into the 'Standard CMS site' category, you create another in the 'Drupal based ecommerce category'. Great. But there is a problem - there is nothing stoping you assigning your site to the 'parent' term of Drupal...

Read more

Query string in drupal menu items

20th Jan 2008

This was written in response to a post on drupal.org regarding query strings in drupal menu items. Currently if you create a drupal menu item linking to an external site with a querystring then this will render correctly. However if you try and use a relative URL (i.e. an internal link) then your querystring will be escaped and the URL won't work.

This override lives in your template.php file and parses all your menu paths for internal links, and will pass query strings into the l function correctly ...


function phptemplate_menu_item_link($item, $link_item) {
  if (!$item['query']){
    $parsed_url = parse_url($item['path']);
    if ($parsed_url['query']...
Read more

Remove the image assist icon from Drupal textareas

20th Jan 2008

This small theme override will allow you to select which Drupal textareas the image assist icon will appear on


/**
 * Theme for adding an image link underneath textareas
 */
function phptemplate_img_assist_textarea_link($element, $link) {
  if ($element['#id']=='edit-body'){
    return theme_img_assist_textarea_link($element, $link);
  }
}

The above code will limit the icon to appearing on only the node edit body fields, you can add more ids as required

Read more

Mod rewrite rules and querystring parameters in Drupal

21st Dec 2007

Just a quick one this, and not strictly Drupal related - but might save you some time when you are writing modrewrite rules to rewrite legacy URLs.

The problem : We had a whole bunch of legacy URLs in the format index.php?Page=SomePageHere which we needed to rewrite to point at some shiny new Drupal URLs.

A simple RewriteRule wasn't working, and after a bit of digging we discovered you can't reference the querystring within a RewriteRule ...

The solution is to use RewriteConditions, so you end up with something like


RewriteCond %{QUERY_STRING} Page=SomePageHere
RewriteRule ^index.php$ new-page-url-here? [R=301,L]

And jobs a good un!

Read more

Allowing HTML in Drupal menu items

16th Dec 2007

You have to be a little careful with this one, but there are many times when in would be very handy to have HTML in your Drupal menu items. For example, you might want your Drupal menu to have a
to force a break, or perhaps insert a around some content to get a two-tone menu item

Add the following to your Drupal theme's template.php file


function phptemplate_menu_item_link($item, $link_item) {
    $output = l($item['title'], 
                $link_item['path'],
                array(), 
                null, 
                null, 
                false, 
                true);    
}

By setting the final paramater on the l function to true, we are telling Drupal that the...

Read more