drupal - how do you override a function that exists in another module -


i override comment_save function. there way override can add in functionality?

is creating trigger such http://drupal.org/node/375833 best way? doesn't seem reliable since happens after fact.

btw, in d6.

it's tricky. first off, i'd suggest instead going , seeing if can manage need using hook_comment ( http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_comment/6). it's more of needed for.

if really need override comment_save, choice around @ things call it. situation, you're lucky - comment_save gets called in 1 place, on line 1542 of comment.module, inside of comment_form_submit.

now, comment_form_submit form submit function - instead of replacing comment_save, can instead make our own custom version of comment_form_submit (and argument's sake, we'll assume we're working in 'custom_module' module) - create new function called custom_module_comment_form_submit, calls variant of comment_save i'm interested in using, , use hook_form_alter() ( http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_form_alter/6 ) set $form['#submit'] replace value 'comment_form_submit' 'custom_module_comment_form_submit'.

this isn't perfect - if install module uses comment_save, you'll need find similar workaround. , if bug or security hole found in drupal fixed in part you're working around here, won't security hole fixed in code. if absolutely must replace comment_save, pretty way it.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -