Drupal coder

Theme variables available to all Drupal template files

When writing themes there's a few values we frequently need to access in our templates. I'm thinking about stuff like "is the user logged in", "is the user an admin", "what is the theme directory" (for referencing images etc)?

The good news is that all these and a few more are available in all template files. Here's a listing of what variables are available and how you can add your own.

May 14, 2010Drupal, theming

Performance tip : disable Drupal's core search indexer when using Apache Solr

Here's a quick tip for people using the (simply awesome) Apache Solr Search Integration module.

The Apache Solr module depends on Drupal's core Search module. This means the Search module will be enabled too when the Solr module is installed. As soon as the core Search module is enabled it starts to index all your nodes and stuff too. This not only takes time to run, but also fills up your database (search_dataset, search_index, ... tables).

Most of the time when you are installing the Apache Solr Search module, you don't need Drupal's core search form and replace the search form with the Apache Solr one using the Apache Solr module setting "Make Apache Solr Search the default:". You have now disabled the core Search module's form, but you have not disabled the indexing. To disable the indexing and save some CPU cycles and database space, just go to your site's search settings page (admin/settings/search) and set the "Number of items to index per cron run" to 0.

search-index-limit.png

Most interesting websites to be kept up to date on Drupal news, module releases, ...

There is a lot of interesting information being published every day about Drupal. My favourite way to be kept up to date of the most important news is using my RSS reader. Over the years I have subscribed to dozens of feeds in my reader. This was getting too much though so I decided to do a little spring cleaning. I reduced my subscriptions to 7 feeds, which I think should keep me in touch of all important developments in Drupal world.

The key to reduce this number is to subscribe to a few aggregator feeds: feeds that are actually an aggregation of other other feeds.

Let's have a look at the list of websites that in my eyes are essential on your reading list...

April 22, 2010Drupal

Drupal's Webform module has Mollom support

I'll even say it once more: "Drupal's Webform module has Mollom support". And I'm not talking support by patching here, but support like "just install Mollom and Webform and eat your ice cream". And boy, we've all waited for this for some time.

To take advantage of this integration, you will need to install the upcoming 3.0 release of Webform. Although this one is still in beta, that shouldn't stop you from using it. The counter is already at BETA-5 at the moment of this writing.

April 20, 2010anti spam, Drupal, Mollom, webform

Automatically create table of contents (jumplinks) for long pages in Drupal

When working on long pages with a lot of headings, a technique often used to give the reader an overview what follows on the page is using a "table of contents" or "jumplinks". Anchors are attached to the all headings and a list of links is added to the top of the page that "jump" to the corresponding heading. Creating and maintaining these jumplinks is a tedious job. Mostly you want the links to be the same as the heading titles and as soon as the titles change, you need to edit the table of contents too.

I've created a small module, called Table of Contents, that creates this table of contents automatically for you by inspecting your node's body and gathering all your heading tags (h1 through h7). The module uses jQuery to do all the heavy lifting. It actually uses a jQuery plugin by Doug Neiner.

I have also implemented a Smooth Anchors jQuery plugin which changes the default "jumping" behavior of browsers to a "scrolling" one.

drupalcoder.com is a blog on all things Drupal in specific and LAMP on OS X in general. It is maintained by Davy Van Den Bremt, a Belgian (Drupal) web developer and designer living in Ghent. The goal of this blog is to log all interesting things that have crossed the writer's path while developing Drupal sites. You can read all about Davy's professional activities on his LinkedIn profile. If you want to get in touch, use the contact form.