Drupal and Taxonomy Weights
- November 25th, 2008
- Write comment
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:
-
function my_module_form_alter($form_id, &$form) {
-
switch($form_id) {
-
case 'taxonomy_form_term':
-
$form['weight']['#delta'] = 100;
-
break;
-
}
-
}
And that's it!
[tags]alter, drupal, form, hook, module, taxonomy, term, weight[/tags]















