Archive for November, 2008

Drupal and Taxonomy Weights

I recently worked on a project in Drupal that called for a large number of taxonomy terms. I needed to put the terms in a specific order, but unfortunately, I had more terms than Drupal's weight field supports, which is a range from -10 to +10.

I did a quick search on Drupal, and was horrified to see how many people are hacking core to add a greater range. This is pretty easy to do without hacking core. All you need to do is create your own module that implements hook_form_alter().

my_module.module

PHP:
  1. function my_module_form_alter($form_id, &$form) {
  2.   switch($form_id) {
  3.     case 'taxonomy_form_term':
  4.     $form['weight']['#delta'] = 100;
  5.     break;
  6.   }
  7. }

And that's it!

[tags]alter, drupal, form, hook, module, taxonomy, term, weight[/tags]

Get Firefox Ad

This is a pretty cool ad for Firefox that just makes me laugh...

Firefox, IE, Opera, Netscape, browsers, funny, ad

Return top

INFORMATION

Drupal development since v4.7