0

I'm a Drupal newbie and trying to customize the 'Add Vocabulary' and 'Add Term' provided by taxonomy using a module named Domain Taxonomy.

To customize it as per my own requirement I'm gonna have to insert the domain specific data when the term is saved without messing up over the existing code provided by domain taxonomy rather wish to override it.

I'm looking for a hook similar to hook_nodeapi where in '$op == presave' after validations and before saving node it can be customized with user added data.

To my understanding hook_nodeapi doesn't apply for stuff like taxonomy or user profile. Does something similar exist for taxonomy that i could put to use here. Kindly let me know if my understanding is flawed and provide valueable comments/feedbacks and possible solution.

1

You can add a validation function to the form in hook_form_alter(). If you give your module a high weight, that validation function will be added last to the validation functions array and thus be executed last. The validation function can call form_get_errors to check whether errors occurred. If no errors occurred, you can be pretty sure that the vocabulary or term will be saved to the database, making it something like hook_nodeapi($op = presave').

Note that you cannot use hook_form_FORM_ID_alter(), because these hooks are executed before hook_form_alter(). Also, I found no easy way to react on the installation of other modules.

1
  • thanks for the reply..but my trouble is there are methods provided by the domain taxonomy that take care of inserting the domain related information during a term or vocabulary insert...all i want to do is make sure the domain related information is passed by my module..else there are no troubles with validations or the insert operations... Oct 12 '11 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.