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.

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

Class 'XMLWriter' not found

In a Red Hat or CentOS server installation, XMLwriter may not be enabled by default. To enable it, follow these steps:

# If you are using the base 5.1.6 php, then
yum -y install php-xml

#if you are using php 5.2 (from the centos 5 testing repo)
yum -y --enablerepo=c5-testing install php-xml

#restart apache
service httpd restart

Drupal and PHP 5.3

There are some problems with running Drupal on php 5.3. There are five kinds of solutions:

  1. Downgrade to php 5.2.6 (not possible in many situations)
  2. modify Drupal to change the error level reporting
  3. find the latest patches to fix the problems
  4. hack Drupal core or contrib yourself to fix the errors (Drupal 6 is already compliant, but not D5)
  5. put a timezone in your php.ini to get rid of timezone errors

Drupal 6

2. Modify Drupal's error reporting --already done for Drupal 6

3. Find patches

Website Releases via Subversion (SVN)

This article was originally posted at:
http://labs.redbd.net/blog/index.cfm/2006/7/5/Website-Releases-via-Subversion-SVN
but this site now seems to be dead, so I have recovered it from archive.org and re-posted it.

If I am breaking any copyrights here, please let me know and I will remove it.

Note that Drupal now blocks any path containing "svn-base". See: http://drupal.org/node/28776


Posted At : July 5, 2006 9:54 PM By : Mark

Planet Drupal links

Useful links to posts on Planet Drupal that I want to remember for later:
How To: Create a Drupal Calendar http://gotdrupal.com/videos/drupal-calendar
33 Most Useful Domain Tools http://mogdesign.eu/blog/33-most-useful-domain-tools/
Top Notch Themes pre-releases a landmark theme called Fusion http://chrisshattuck.com/blog/top-notch-themes-pre-releases-landmark-the...
A simple Drupal internal linking strategy http://chrisshattuck.com/blog/i-can-haz-some-google-love-simple-drupal-i...

Managing Acquia Drupal with dget, dsite and dsvn

#place to put dget scripts

DGETDIR=/root/dget


#get dget suite and install it, editing settings.sh if necessary

svn co http://drupal-get.svn.sourceforge.net/svnroot/drupal-get/trunk $DGETDIR
cp $DGETDIR/rename_to_settings.sh $DGETDIR/settings.sh
$DGETDIR/setup.sh $DGETDIR

#check out drupal core, contrib

dsvn checkout

#use dsite checkout if no need to commit from this site
#and optionally, the Acquia distribution (ignore any warning at the end)

dsvn checkout x x a6paths

Notes on Drupal and Subversion

Putting this code into a page will let it update the site from a repository:

<pre>
<?php system( 'svn up sites/default/...'); ?>
</pre><h1>Done!</h1>

Note that apache must have write permission for the whole directory tree.
I tried the following but couldn't get it to work (probably not in my version of PHP):
svn_checkout('http://myserver.com/svn/demo', '/var/www/html/demo/temp');

If the repository requires a password for update, the following can be done:

Syndicate content