uber's blog

ParkroseHardware.com Goes Drupal!

We just launched the new version of http://www.ParkroseHardware.com in Drupal. The conversion began last January and the new website boasts an extensive online database of photos and details of the entire Rental department.

We used a significant number of js enhancements to make the site look current as well as user-friendly, including lots of views plugins, and modals powered by Lightbox 2.

Pass $_GET inside $destination

How to add multiple $_GET variables to the $destination such as with drupal_get_destination()

While it is possible to do something like the following with a single passthrough $_GET var:

drupal_goto('node/123', '&destination=node/add/screening?screening=1')

It breaks down when you need more than one, such as here:

drupal_goto('node/123', '&destination=node/add/screening?screening=1&type=movie')

Project Starting Point Just Made Public!

I have just completed a public version of a framework I've been developing for the last ten years as a basis for web projects. It is called Project Starting Point or PSP. Click here for a screencast and more info.

How to Determine the Acquia Version Number

If you find a folder inside/modules called acquia, you have an Acquia distribution of Drupal. To determine the version number of your installation, independent of an active Acquia subscription, look for the following file and open it. It will contain a line that tells the version number, see example below.
/modules/acquia/acquia_connector/acquia_agent/acquia_agent_drupal_version.inc

define('ACQUIA_DRUPAL_VERSION' , '1.2.22 (Drupal 6.16 core)');

OSX 10.6.3 broke Komodo IDE 5.2.4 (it seems)

04/01 update: There was a file in my startup items called LCCDaemon, a controller for Logitech devices, that was somehow conflicting with Komodo in the new OS. I removed it and all was working again. Thanks to Todd at ActiveState for helping point me in the right direction!

Clone a Drupal Node and Give to Another User

Here's a little Drupal 6 snippet that will take a nid and create a copy of that node and assign it to another user. $account needs to be a valid user object.

$node = node_load($master_nid);

//make sure we're really cloning a node
if (!empty($node->nid)) {
  $node->created = '';
  unset($node->nid);
  unset($node->path);
  node_save($node);
  
  //match the node to the owner not the logged in user, in case admins create users
  //to do these we have to go around node_save since it uses the logged in user

Drupal FAPI Node Title #weight Not Working

I was struggling with setting the weight value of the title field on a cck node type today. When i set the weight on the title it didn't work like on other fields. The problem is that there is a key in the $form array called #content_extra_fields, which is actually controlling the form placement in the node_edit_form. The way to do this is set the weight in two places like such:

//title
$form['title']['#weight'] = -38;
$form['#content_extra_fields']['title']['weight'] = -38;

Redirect User by Role Upon Login

Disclaimer: This post will only help the developers out there as this is a snippet designed to be placed inside another module.

I generally create at least one "basic" module for every site I build. I would place the following code in said module:

/**
 * Implementation of hook_user
 *
 * @see http://api.drupal.org/api/function/hook_user
 */
function modulename_user($op, &$edit, &$account, $category = NULL) {
  
  $start = '';
  
  if ($op == 'login') {
    
    //redirect based on role
    
    //role = 'some role'
    if (in_array('some role', $account->roles)) {

Drupal Admin Theme

I was looking for a stock theme to use for a client as a backend/admin section for Drupal and came across the RootCandy project. This looks very promising. Here is the link http://drupal.org/project/rootcandy.

How To Preset the Next Node Id In Drupal

I needed to predict the NID of certain nodes on a project; I needed to make sure the nid for my next node was x and not y. How to do that? How does Drupal determine the nid of the next created node?

A quick scan of the node module pointed me to the fact that it just grabs the auto_increment value from the node table. Therefore, to predetermine the next created nid, just set the auto_increment value to the desired value. This is easily achieved with phpmyadmin by selecting your table, clicking on operations, and looking in the lower left corner for the box marked "auto_increment".