Drupal Tutorials

Drupal 6 page template suggestions

In this Drupal tutorial we will look at how to specify a page template file (page.tpl.php) based on the content type of the particular node in question.

This technique will allow us to have different page layouts for different content types (like different templates for regular pages as opposed to stories).

The technique is called template suggestion and will indicate to Drupal which files it should look for when determining what page template to use for a node based on the node's content type.

PHP Memory Limit and htaccess

The PHP memory limit will need to changed sooner or later as we start writing and running more resource intensive scripts. The idea of a memory limit is important on a web server since the server may be serving many requests at a given time, and we wouldn't want any one request or script consuming too many resources. Also, it is useful to limit how much memory a script can consume in a setting (like a VPS) where resources like RAM are limited.

Remove 'Preview' button in Drupal 6 comment form

By default in Drupal 6, there is a 'Preview' button in addition to a 'Save' button in the form which allows a user to post a comment.

For those of us who think it is silly to have a preview before posting, the good news is that you can remove the button quite simply with a bit of code.

Place the following code in the template.php file which exists in the directory for the theme that you are using. If your theme does not use a template.php file, go ahead and create one.

This code goes in template.php:

<?php

Adding rel="nofollow" to Comments in Drupal 6

By default in Drupal 6, only the Homepage link of a commenter has a rel="nofollow" attribute attached to it. The commenter has free reign on all the other anchor tags inside the body of the actual comment. In many cases this is unsuitable especially for SEO purposes.

Spammers like to leave links in comments to transfer Pagerank from your page to theirs. By adding a rel="nofollow" attribute, no Pagerank will be passed to the external page and it will also serve as a deterrent to adding external links in the first place.

Disable Resizable Textarea Drupal 6

Drupal 6 allows textareas to be re-sizable and this may be a useful or annoying feature depending on how you look at it.

It may be useful since you are allowed to change the size on the fly to suit your needs and may be helpful when adding a lot of content at one time.

It may be a nuisance since an extra image (grippie.png) has to be loaded from the server to provide that functionality.

Using wget and an XML Sitemap to Spider website - Keeping the Drupal cache warm

This tutorial will speak in the context of using this technique on a website which uses Drupal for content management. This technique need not be limited to a Drupal website and should work well if adapted properly.

Drupal caching, when enabled, causes the system to store copies of generated pages to help the next request for the same page go faster. You specify the cache lifetime when setting up caching, and any pages in the cache which are older than the lifetime you specified are removed from the cache on the cron run.

Protect cron.php in Drupal 6

By default, anyone can run cron.php on a Drupal 6 installation. That means everyone with access to your website can run your cron.php file. Since cron.php is used for maintenance it would make sense that it is prevented from being run arbitrarily; whether or not an outsider running it can cause damage is merely a side issue.

Why can't I edit a node that I have permission to edit in Drupal?

In Drupal, sometimes when you add the appropriate permissions for a user to be able to edit a node you are surprised when no edit tab comes up and if you navigate to the edit URL directly you get an "access denied" error.

If you think you have added the permissions correctly and cleared all the relevant caches, the following may help you solve your problem. It turns out that you may not have added the permissions correctly after all.

Drupal 6 - Adding an Above Comments Block to a node

In this Drupal tutorial, we will look at how to add a block which comes right before the comments for a node. At times it is necessary to add some content on a node but it should come before (above) the comments for that node. For example, you could want to display an advertisement or links for sharing or any other content like that.

Adding an above contents block can be done in 3 steps as the tutorial below shows.

Remove Homepage Textbox from Comment Form in Drupal 6

In this tutorial, we will look at how to remove the homepage textbox from the default Drupal 6 comment form.

You may want to remove this textbox to clean up the default comment area that Drupal renders out of the box, or you may simply not want users to be able to leave links to their homepage.

Whatever your reason, we will see how to rectify the issue in the tutorial below.