Content Taxonomy http://drupal.org/project/content_taxonomy by mh86 is an interesting and useful addition to the core taxonomy. It is useful when you need additional taxonomy field on your CCK content type.
But there's one more feature - it hides default taxonomy fields from content types by default. What if you need to see Content Taxonomy field and the original vocabulary at the same time on that node?
This particular point was bothering me all the day today. Can I hack the module? No, that is ugly (however I can suggest a patch later probably, but I need a working solution today).
Should I make a procedure listing all the terms from Content Taxonomy field and adding these back to form then? Would it work with Content Taxonomy RC3 etc?
Is there an easier workaround? Upon thinking it over again, obviously there is (here's the snippet you can use at your custom module which weight is greater then Content Taxonomy's - db_query("UPDATE {system} SET weight = 2009 WHERE name = 'custom_vito'"); etc) :
<?php
/**
* Implementation of hook_form_alter().
*/
function custom_vito_form_alter(&$form, $form_state, $form_id) {
// lets reuse a bit of stuff kindly given to us by <a href="http://drupal.org/user/59747">mh86</a>
if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id && isset($form['taxonomy'])) {
$_content_taxonomy_vids = array();
$info = _content_type_info();
$content_type = $info['content types'][$form['type']['#value']];
foreach ($content_type['fields'] as $field) {
if ($field['type'] == 'content_taxonomy' && (!in_array($field['vid'], $_content_taxonomy_vids))) {
$_content_taxonomy_vids[] = $field['vid'];
}
}
if ($_content_taxonomy_vids) {
// then let Taxonomy module repair what was broken by Content Taxonomy
taxonomy_form_alter(&$form, $form_state, $form_id);
}
}
}
?>voila! ;)
- vito's blog
- Login or register to post comments
Recent comments
15 weeks 4 days ago
15 weeks 4 days ago
29 weeks 3 days ago