Drupal tips

Command line Drupal install and update script for multi-site hosting

Maintaining a Drupal site, or a collection of sites is much easier if everything is kept completely separate--Drupal core, contributed modules, and the site itself.
This is even more important if multiple sites are hosted on the same server. Drupal's own multi-site support can be a nightmare to maintain, believe me! (e.g. when you want to upgrade modules or core).
A must simpler and easily supported configuration is to keep everything separate and to use symbolic links to tie it all together. For example, I keep:

Technical Notes

These notes are my personal online notebook of useful commands and "how-to's". You are welcome to make use of them if you find them helpful. They obviously don't come with any warranty! Click on one of the category tags above for the notes in any category.

updating webform from 2.x to 3.x

There are two changes that need to be made.

Drupal Video Players

Modules

Theming CCK fields in Drupal 7

Drupal node display can be overridden using a template file of the form:

  • node--content_name.tpl.php

The simplest way of displaying fields is to use the render() function

The render array is documented here: drupal.org/node/930760

  • Individual field values can be found in one of:
    • render($content['field_name'] fully rendered value
    • $content['field_name']['#items']['0']['safe_value'] will include paragraph markup
    • $content['field_name']['#items']['0']['value'] raw
    • $content['field_na

Drupal 6 to 7 upgrades

The "Support" module on Drupal

Some notes on configuring the module

  • Follow the online instructions, but also
    • set the support content type not to be on the front page
    • set the from email address to be do-not-reply@mydomain
    • Default sort: State/ascending
    • Secondary sort: Last update/descending
    • Modify the new and updated ticket email to be something like this:
Please do not reply to this message but update the ticket with any responses.

!update_username has created the ticket '!ticket_subject':
!ticket_url

Ticket text:
------------------------------
!ticket_body------------------------------

Deleting large numbers of comments from Drupal

  • You can easily delete all comments with:
DELETE FROM comments;
  • The problem comes when there are good and bad comments, and you only want to get the bad comments. -The cleanest way is to delete all the rogue users first. That will set the UID on their comments to 0, so you can delete all their comments by running:
DELETE FROM comments WHERE uid=0;

Resources for creating a new drupal module

This is my quick reference of useful links
Module developer's guide: http://drupal.org/developing/modules
Coding standards: http://drupal.org/coding-standards
Doxygen and comment formatting conventions: http://drupal.org/node/1354
Apply for contributions CVS access: http://drupal.org/cvs-application/requirements
and then: http://drupal.org/cvs-application

Themeing CCK output in Drupal

There seem to be several ways of getting CCK fields into your node-typename-node.tpl.php file:

  • First using the _rendered variable which will give both the label and the content: <?php print $field_website_rendered; ?>
  • Second using 'view' which will just give the contents of the field:<?php print $field_website[0]['view']; ?>
  • Two methods recommended by Front End Drupal. First using 'safe': <?php print $node->field_website[0]['safe']; ?> seems to fail all the time
Syndicate content