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:
- install xampp at c:\xampp
- modify c:\xampp\apache\conf\httpd.conf
- the line 'Listen 80' to 'Listen 88'
- If you had Clean URLs on your remote site (i.e. localhost/drupal/admin instead of localhost/drupal/?q=admin)
- #LoadModule rewrite_module modules/mod_rewrite.so' to ' LoadModule rewrite_module modules/mod_rewrite.so' (take out the #)
- AllowOverride None to AllowOverride All
- start apache and mysql from the xampp interface (you may need to change mysql configuration)
- copy over the following folders to a new 'drupal_remote_site' folder on your local machine
- Themes
- Modules
- Files
- if you don't already have the Backup and Migrate module on your remote machine, install it
- backup your database on the remote machine, copy this into the local folder 'drupal_remote_site'
- 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)
- copy in your themes, modules, and files folder into this new drupal folder
- go to http://localhost:88/drupal/install.php, this will install necessary tables,etc. into the db
- now enable the Backup and Migrate module on the local machine
- use the 'Restore/Import DB' tab in drupal to import your db
- 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
For example:
[field_image_fid] => stdClass Object ( [content] =>
can be accessed in your tpl.php by:
$fields['field_image_fid']->content
Subscribe to:
Posts (Atom)