Drupal Updates

Tuesday, January 17, 2012

Unable to update users_roles table from hook_user

Description:
Following code for hook_user was not working on one installation of drupal :
function testform_user($type, &$edit, &$user, $category = NULL) {
switch ($type) {
case 'insert':
$sql = 'INSERT INTO {users_roles} (uid, rid) values (%d, %d)';
db_query($sql, $user->uid, 3);
break;
}
}

The values just will not insert into the database. No error messages, nothing. Suspected a module conflict.
Solution:
Isolated the issue to the ‘workflow_ng’ module. I didn’t need the module so disabling it fixes it for me.

Friday, May 7, 2010

Drupal: Fatal error: Call to undefined function: user_access()

Issue: Fatal error: Call to undefined function: user_access()
How I fixed it:
1. Open the System table in the database
2. Look for the entry ‘modules/user/user.module’ under the ‘filename’ column
3. If the value for ‘status’ is 0, change it to 1.
4. Save.

Drupal: HOWTO – Link teaser to node in a View

This is how its done in Drupal 6:

First, create a view with a Teaser field any other fields you may require. Then:

1. Add field Node:Nid
a. select option ‘exclude from display’
b. re-order the position to make it the first field
2. Edit the ‘Teaser’ field
a. check ‘output this field as a link’
b. set the path as ‘node/[nid]‘
3. Update, Save and you should be good to go.

Drupal: simple multistep preview

This is my simple implementation of a multistep preview for any node type. It is basically a ‘toggle’ method which removes the form in one page and removes the preview in the other so you only see the preview or only the form at a given stage. Maybe a little messy, but it works!
Taxonomies have not been taken into consideration in this code. Leaving that to figure out for yourselves (Hint: $form['taxonomy']).

Drupal: HOWTO – Link teaser to node in a View(Drupal 5)

Someone asked me how to link a teaser to node in a View using Drupal 5.
This is how it could be done in a list view:
1. Change the view type to list view
2. Add your teaser field and any other fields you need
3. You add the node id field and save the view
4. Go to example.com/?q=admin/build/views/wizard, and select the view
5. Make the theme type simple list
6. Click select theme type
7. Paste all the code in the correct files
Your view should be showing with the node ids by now. Next, we go and convert our node ID into a URL in the theme

Click here to view the rest of the solution.