Drupal articles

Making a drupal views block title link back to the view

24th Jan 2009

One for the small but handy category this. The standard "more" link the views module adds to it's blocks has no place on a modern accessible website, you really need a more verbose link in there. One solution has always been to add a bit of footer or header text into the block, but it's a little tedious - and clients always find views hard to edit.

This simple solution will turn the block title into a link to the view, it goes into your template.php _phptemplate_variables function


  if ($hook=='block'){
    $block = $vars['block'];
    if ($block->module == 'views'){
      $view = views_get_view($block->delta)...
Read more

File uploads in Drupal 6 - Part 1

21st Jan 2009

So you've got a nice new version of Drupal 6 and you're building a form, but you want to allow users to upload a file. Of course this is easy with Drupal, and we covered how to do just that, but for Drupal 5, in our previous article: Example code to build an upload form in Drupal. Here we show how file uploads are done in Drupal 6.

Honestly, not much has changed, here's the code to get your file upload element onto your form:


function build_upload_form(){
    $form['#attributes'] = array('enctype' => 'multipart/form-data');
    $form['file_upload'] = array(
        '#type' => 'file',
        '#title'...
Read more

Organising your views in Views 1.x

17th Jan 2009

If you're still stuck in the Views dark ages, and 1.6 is as good as it gets for you here's a quick tip to make things a little easier:

Exporting your views

You've just spent a good hour creating and tweaking that view until it shows exactly the right thing, and now you want to save it for posterity, portability and all that jazz.

Simple. Click on the 'Export' tab within Views and you'll get a lovely version of your view in code, which you can pop in an implementation of hook_default_views() and you're done, almost.

That's all well and...

Read more

Using mollom with Drupal

15th Jan 2009

We have recently started using Mollom on our Drupal site. Mollom is a clever anti spam service, that combines auto SPAM detection techniques with a normal CAPTCHA. The idea is simple, Mollom will check form submissions, if it thinks something is SPAM then it will prompt the submitter to complete a CAPTCHA. This means that you don't risk losing valid submissions to an over aggressive SPAM filter, and you don't risk scaring off users with an un-necessary CAPTCHA.

Setup is simple you need

  • An account on Mollom http://mollom.com/ (there is a free limited account, or a full account for 30...
Read more

How to capture SugarCRM leads in Drupal

31st Dec 2008

We are big fans of SugarCRM and have worked on a number of projects to integrate SugarCRM with Drupal. This is a simple guide to performing a basic data capture integration between Drupal and Sugar, using a couple of Drupal modules (webform and sugarwebform). You can see an example of this on our contact us page - feel free to fill the form in, but it is our live contact form so don't be suprised if you get a callback :)

Install the Drupal Sugar modules

We are assuming here that you have both SugarCRM and Drupal up and running...

Read more

Drupal 6 tinymce button layout problem

28th Sep 2008

We had a problem today with tinymce on Drupal 6, with a large number of buttons enabled the width of the tinymce button area just kept on growing - not pretty

Adding the following CSS to our Drupal 6 theme solved the tinymce button problem


.defaultSkin table.mceToolbar,
.defaultSkin tr.mceFirst .mceToolbar tr td, 
.defaultSkin tr.mceLast .mceToolbar tr td {
  float:left;
}

.defaultSkin table.mceToolbar{ float:left; }

Read more

Drupal - imagecache problems with special characters

27th Sep 2008

We came across this problem on one of our Drupal sites the other day, someone uploaded an image with an ampersand in the filename, and imagecache refused to display the image. A bit of investigating revealed that imagecache had a problem with a number of special characters in the image filenames.

The solution is a little imagecache theme override - you can see examples for both Drupal5 and Drupal6 below

Drupal 5 version


function phptemplate_imagecache($namespace, $path, $alt = '', $title = '',
    $attributes = NULL) {
    $attributes = drupal_attributes($attributes);
    $imagecache_path = file_create_url(file_directory_path() .'/imagecache/'.
    $namespace .'/'. drupal_urlencode($path));
    return '
Read more

Remove tinymce from drupal block edit page when format is set to PHP

20th Sep 2008

Small one this to compliment our other article on removing tinymce from select textareas. This enhancement will hide tinymce from the Drupal block edit screen when the input format is set to PHP. This stops the problem of tinymce stripping the PHP tags from the block edit textarea when you edit your block

The following function goes into your template.php file and will solve the problem of tinymce showing up on a block when the format is set to PHP


function phptemplate_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
  print $textarea_name;
  switch($textarea_name){
    //add text areas to disable tinymce for
    case 'log':
      unset($init)...
Read more

Displaying exposed filter form for views in Drupal 6 (views 2)

15th Aug 2008

One of the joys of working with Drupal 6, and views 2, is that you have to relearn a lot of things you used to take for granted ... one trick we use in most projects is embedding views filters in blocks, nodes or custom code. There are plenty of scenarios this is useful, the classic being to create a flexible views based replacement for the normal Drupal search. Anyway, enough of the blurb - heres the good stuff - some code to give you the filter form for a Drupal 6 views 2 view.


  $view = views_get_view('your_view_name');
  $view->set_display('default');
  $view->init_handlers()...
Read more

Drupal running on lycos webhosting - 500 internal server error

3rd May 2008

Another quick one this, we recently had a small client experience issues with their Drupal site which was hosted on lycos webhosting. They hadn't changed anything on the site, but suddenly they were getting nothing but 500 (internal server) errors.

The solution turned out to be the .htaccess file, and specifically the following 2 lines


Options -Indexes
Options +FollowSymLinks

Commenting them out solved the problem and the site was back up and running.

Read more