My Top Drupal Tips

By Pete | @kingpetey | 15 Dec 2007

I've been developing web sites using Drupal for over 18 months now, for me the flexibility and modules available for Drupal make it the best and quickest way to develop a website. Here are some of my top tips:

1. If you want to edit the layout of the site maintenance page you can find the CSS file in misc/maintenance.css.

2. After I have installed Drupal I first enable clean URLs then enable the path module. This means I can build basic SEO in from the start. If building a blog or articles based site I like to use the path auto module to automatically specify the URL.

Clean Urls

3. When designing a site I like to build it in Dreamweaver first, then I copy the PHP template tags in from another template (often bluemarine). In the past I would customise the garland theme however there was a lot of extra CSS that I would often remove.

4. To create a template for an individual node type create a file in your template directory called node-nodetype.tpl.php where nodetype is the node type. (ie node-story.tpl.php for a story node).

Node Story
This is really useful for customising individual nodes especially when using CCK and the views module. For instance I recently built a ticket support system for a company, by integrating a view into the company node you could immediately see the open tickets for that company.

//load the view by name
$view = views_get_view('view ticket');
//output the top three items in the view with the node title as an argument
print views_build_view('embed', $view, array($node->nid), false, 3);

The above code is for inserting a view into a node - more in the views documentation.

5. When first developing a theme I change the administrative theme to Garland or Bluemarine so that I can still access all the administration sections in order to enable menus, blocks, CCK and other configuration options.

6. In Drupal 5 a top border is added to tables. If this messes up your theme edit modules/system/system.css and comment out or remove line 18 ( border-top: 1px solid #ccc; ).

7. The TinyMCE module allows you to turn a text area into a WYSIWYG editor giving you formatting options such as bold, italic, underline, text direction, links and images. The module IMCE adds image upload and resizing support to TinyMCE.

8. When upgrading from Drupal 4.7x to 5x I often have problems with IMCE not working with TinyMCE, to revolve this remove the TinyMCE profile and recreate it.

9. If you enable a lot of modules you may get php memory errors, to fix this add:
ini_set('memory_limit', '20M');
to the sites/default/settings.php file. You may also have to do this on the pages that have the errors to.Memory Set

I usually add it after the other ini_set variables in the settings.php file.

10. When developing I like to have the cache disabled, once the site is ready to launch I will set it to normal mode. The same goes for aggregating and compressing CSS files.

11. When having to create user profiles I use the node profile module along with the CCK (content construction kit) module rather than the profile module included with Drupal as default. CCK gives you a lot more flexibility and there are many more customization options. Also by making a profile a node you can theme it easier (see #4).

12. In Drupal 5 you can specify a default front page from the site information page however an easy way to create different front pages for authenticated and non authenticated users it to use the front page module.