Drupal

CCK form field changes using Drupal's hook_form_alter don't work? Use #after_build

Submitted by charles on

I ran into issues when trying to use drupal's hook_form_alter to change some attributes of cck fields in a node form. It appears that depending on the weight of the module the form_alter is in, it might get called before the actual form element has been processed.

To make sure, you can set a function to be called after the form has been properly created, but before rendering.

In your form alter, add the after build key to the form field's array:

$form['field_course_status']['#after_build'][] = 'course_disable_status_field';

KAYA FM interview: DISCOVER MORE- THE BUSINESS OF BEING ONLINE.

Submitted by charles on

These are the notes from my Kaya FM interview on the business of being online:

1) What are some of the main things small businesses need to consider when looking at setting up a website?

I really think the most important aspect of setting up a web site, is planning. Think how a house is built – you don’t jump straight in and start building – No. You first think about the ideal house that you want, and then develop the plans for that house, based on your specific needs and your financial situation. It’s exactly the same with building a website.

Drupal Johannesburg July 2008 meetup summary

Submitted by charles on

The third Drupal Johannesburg meetup took place on the 19 July 2008 at Obsidian Systems, and was well attended, by around 25 people (I didn't count, just guessing). While we are still feeling our way around the structure of these meetings, this month's meetup was a step in the right direction. Andre from Cerebra gave a workshop to demonstrate the power of Drupal's CCK module. During the workshop he created a site which allows users to post reviews of cell phones. Some of the modules he used were: contemplate for quick theming of content type data - we were warned not to leave the generated code in contemplate, but to then create a node template and paste the code there, as this is more maintainable because it's not stored in the database. He used the automatic node titles module (plus token) to create useful, and search engine friendly titles.

Disable tinymce for fields in drupal module: webform

Submitted by charles on
I normally disable tinymce for certain textareas by overriding the tinymce function theme_tinymce_theme. This allows me to target textareas by their name attribute. For example, to disable the editor for all cck fields that I have named 'description', and all the devel modules 'php code' block textareas, one would put the following in that function: function phptemplate_tinymce_theme($init, $textarea_name, $theme_name, $is_running) { switch ($textarea_name) { // Disable tinymce for these textareas - using the field's name attribute

Make a user agree to a drupal site's terms and conditions

Submitted by charles on
Came across a module that does exactly this, the Legal module. When an anonymous user registers to use a drupal site, they get presented with the normal registration form with the terms and conditions of the site below. If an administrator adds a user, the first time the user logs in, before they can go any further, they need to accept the terms and conditions. In both cases, it's just a checkbox at the bottom of the terms and conditions that they must check before being allowed to continue.

Drupal support irc channel

Submitted by charles on
If you can't find what you're looking for on the drupal site, you might want to try the drupal support irc channel, and ask your question there. Using your irc client, login to: /server irc.freenode.net [after connecting successfully] /join #drupal-support

Drupal CCK email field errors: "doesn't have a default value query"

Submitted by charles on

Ran into this error a couple of times before when adding content to a CCK email field in MySQL 5.0.27: user warning: Field 'field_email_email' doesn't have a default value query: It seems the email field is initially set up to not allow null values. To fix this check out this patch or just update the field in phpMyAdmin: ALTER TABLE `table_name` CHANGE `field_email_email` `field_email_email` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL

Drupal path not available to anonymous users in view block

Submitted by charles on
I created a view in drupal with some argument handling code. This code loaded the node so as to get the value of the path alias. I then used this path alias as a taxonomy argument for the view: if ($type == 'block' && arg(0)=='node') { $node = node_load(arg(1)); $path = $node->path; $args = array(); $args[0] = ''; if (!empty($path)) { $args[0] = $path; } return $args; }