Wednesday, December 10, 2008

distinct Drupal user list with views

having trouble displaying a DISTINCT user list with views? This problem often arises because you need to choose the 'user' type view when you are first creating the new view.

Tuesday, December 9, 2008

Drupal Views Templates and CCK $fields Array

Having difficulty accessing the $fields array under your Drupal Views template? Are you sure you have named your template correctly (for instance, if you have named it with 'field' instead of 'fields' the template will apply to individual fields, for which the $fields array is not exposed)

Thursday, December 4, 2008

How to migrate Drupal to xampp for Development



Occasionally it is important to work on a local development machine. For this task I often use the xampp package, which mirrors a standard lamp stack.

To migrate an existing remote drupal site do the following:
  1. install xampp at c:\xampp
  2. modify c:\xampp\apache\conf\httpd.conf
    1. the line 'Listen 80' to 'Listen 88'
    2. If you had Clean URLs on your remote site (i.e. localhost/drupal/admin instead of localhost/drupal/?q=admin)
      1. #LoadModule rewrite_module modules/mod_rewrite.so' to ' LoadModule rewrite_module modules/mod_rewrite.so' (take out the #)
      1. AllowOverride None to AllowOverride All
    3. start apache and mysql from the xampp interface (you may need to change mysql configuration)
  3. copy over the following folders to a new 'drupal_remote_site' folder on your local machine
    1. Themes
    2. Modules
    3. Files
  4. if you don't already have the Backup and Migrate module on your remote machine, install it
  5. backup your database on the remote machine, copy this into the local folder 'drupal_remote_site'
  6. install the same version of drupal on your local machine which you had on your remote -- note: this downloads as a tarball which must be expanded and copied into within c:\xampp\htdocs\drupal (rename the copied folder as drupal from drupal-6.5 for instance)
  7. copy in your themes, modules, and files folder into this new drupal folder
  8. go to http://localhost:88/drupal/install.php, this will install necessary tables,etc. into the db
  9. now enable the Backup and Migrate module on the local machine
  10. use the 'Restore/Import DB' tab in drupal to import your db
  11. voila, all should be back to normal

Wednesday, December 3, 2008

The $fields array in Drupal (CCK)

the $fields array is very important for accessing field content when doing custom theming. Unfortunately field names are not well documented, nor are they intuitive. For example, the field name for a node:link field is view_node. In order to track down names of my fields I usually use print_r ... the trick here is that you must look for 'stdClass Object', almost always the index giving these objects as values are the names of the fields used within the $fields array.

For example:
[field_image_fid] => stdClass Object ( [content] =>

can be accessed in your tpl.php by:
$fields['field_image_fid']->content