1

I have a custom sub-theme of the Seven theme. The Seven theme makes some node alteration via seven_form_node_form_alter(). I would like to have seven_form_node_form_alter() not run at all or I would like to overwrite it. How can I accomplish this?

I tried hook_module_implements_alter() but there was no implementation of Seven in there. (I'm wondering if that only works with modules.)
Another thought was hook_theme_registry_alter() but I couldn't see anything there about form alters.

2

hook_module_implements_alter() allows just to alter the hooks implemented by modules, and hook_theme_registry_alter() alters only the theme functions, not hooks.

If you look at the code of drupal_alter(), the function that invokes all the alter hooks, you will see the following code, which deals with alter hooks implemented by themes.

// Allow the theme to alter variables after the theme system has been
// initialized.
global $theme, $base_theme_info;
if (isset($theme)) {
  $theme_keys = array();
  foreach ($base_theme_info as $base) {
    $theme_keys[] = $base->name;
  }
  $theme_keys[] = $theme;
  foreach ($theme_keys as $theme_key) {
    $function = $theme_key . '_' . $hook;
    if (function_exists($function)) {
      $functions[$cid][] = $function;
    }
    if (isset($extra_types)) {
      foreach ($extra_types as $extra_type) {
        $function = $theme_key . '_' . $extra_type . '_alter';
        if (function_exists($function)) {
          $functions[$cid][] = $function;
        }
      }
    }
  }
}

The alter hooks implemented by the base themes run first; if you have a sub-theme, and that is the current theme, its alter hook will run last. The only thing I see you could do is (in the implementation of the same hook done from your theme) to remove the changes introduced by seven_form_node_form_alter() that you don't want in your theme.

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.