Drupal tips

Notes on Drupal and Subversion

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

<?php system( 'svn up sites/default/...'); ?>

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

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

#now log in to destination site

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

Drupal Database Access

Single node output: Sony use Drupal

Get many items using an object

Theming Views 2

This is a very useful resource: http://www.group42.ca/theming_views_2_the_basics
Note that if you have an admin theme, then the views themeing tool will miss your templates, since it will be looking at views templates in the admin theme!
It will still work ok, it just won't show up on the views admin page.

Themeing Views 2 in Drupal 6

Creating a Data Room with Drupal

Steps to create a "Deal Room" with Drupal

  1. create site, ideally a numbered third level domain, such as 1234.mydrupalsite.com
  2. Go to site / configuration / file system and set download method to private (for obvious reasons)
  3. enable the modules:
    • contact
    • path
    • profile
    • search
    • statistics
    • tracker
    • upload
    • pathauto (contrib)
    • token (contrib)
  4. Configure the theme and administration theme

Drupal upgrade notes

Some notes to remember while upgrading from one version of Drupal to another:

  • do database backup (dget backup databasename)
  • install the update-status module before upgrading and check that all the old modules are up to date
  • warning that this is not 100% accurate if there are CVS modules or others without proper release dates. The date module seems to cause problems and might have to be manually checked for the latest version
  • make sure update-status is removed together with any other un-needed modules

Drupal 7 SEO resources

Syndicate content