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.

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:

Drupal bookmarks

Moving a Drupal site

The following assumes that you are using the dget scripts for managing the site
#log into source site and go directory containing web root

dirname=putwebdirectoryhere
dbname=putdrupaldatabasenamehere
cd $dirname
dget backup $dbname
cd ..
rsync -av $dirname username@targetsite:
#optionally delete backup: rm $dirname/$dbname_*

#now log in to destination site

dirname=putwebdirectoryhere
dbname=putdrupaldatabasenamehere
cd $dirname
echo "CREATE DATABASE $dbname CHARACTER SET utf8 COLLATE utf8_unicode_ci;" | mysql -u root -p
dget restore $dbname

Misc Drupal database queries

This are probably not of general interest, just some example queries from a particular database that I wanted to save here as snippets.

--view all category titles from node: n & d, category node: c
$sql="SELECT n.nid, c.title AS cname, d.field_catcache_value AS cat FROM node AS n"
. " JOIN content_type_document AS d ON d.nid=n.nid AND d.vid=n.vid"
. " JOIN node AS c ON c.nid=d.field_category_nid"
. " WHERE n.type = 'document'";

--get the body of the category definition c from a given node n & d
SELECT n.nid, c.title, r.body AS cname FROM node AS n

Syndicate content