1

i'm trying to implement lightweight topic tracker for core forums (tracking new topics and comments on main forum view).

I'd like to override forum_forum_load() method, but core forums calls forum_forum_load() method inside of a forum_menu_local_tasks_alter() and besides my overridden mymodule_forum_load() and mymodule_local_tasks_alter() it'll still call core forums own forum_forum_load() method making 2x more queries (2 x Amount of forums, in this case 28x2).

I replaced forum load function call inside of forum_menu_local_tasks_alter() with my own function and seems like it's working just fine, but I don't want to mess with the core, so I'd know if there is other way to prevent that behaviour.

I tried some other forum extending modules and they all have exactly same problem.

2

You're right in not wanting to mess with core; it makes things tricky when you're trying to update to a new version of Drupal. You have to maintain patch files which may break with new core code and it just gets messy.

Fortunately Drupal does provide a method to handle exactly what you're after.

In Drupal 7 hook implementations are alterable, so you can use hook_module_implements_alter() to stop forum_menu_local_tasks_alter() from ever running:

function MYMODULE_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'menu_local_tasks_alter') {
    unset($implementations['forum']);
  }
}

You'll need to copy the code from forum_menu_local_tasks_alter() and put it in your own mymodule_local_tasks_alter() function, and just replace the call to forum_forum_load() with the call to your mymodule_forum_load() function.

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.