Skip to main content
replaced http://drupal.stackexchange.com/ with https://drupal.stackexchange.com/
Source Link

This question relates to How do I redirect a taxonomy menu item to another path?How do I redirect a taxonomy menu item to another path?

I followed the recommendations of Clive and wrote a hook_menu_alter to provide my callback.

function material_menu_taxonomy_page_callback($term) {
  dsm('Entered material menu callback');
}

function material_menu_menu_alter () {
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_menu_taxonomy_page_callback'; 
}

I placed a code line dsm("Altering"); in the callback to see where in the process the callback is being called, but it never shows up.

I am fairly certain that I have the code correct.

  • The hook has the name of the custom module.
  • The callback name is correct.
  • the callback is in the same file as the hook
  • I have turned the module off and then on so that I can be sure that Drupal knows about mymodule_menu_alter
  • And I have flushed the caches.

My assumption is that mymodule_menu_alter()' should change the callback in the menu item array and that the callback will be called each time the menu item is selected. That suggests that my dsm()` message should display at the top of the page requested by the menu.

While Clive's test indicated in his answer worked, my revisions did not. Following Clive's answer recommendations I revised the code as follows.

material.info file contained in modules subdirectory = sites/all/modules/Custom/material

name = Materials  
description = Redefine the path for materials menu
package = CR-Hub
core = 7.x
; Includes
files[] = material.module

material.module file in same subdirectory

function material_taxonomy_page_callback() {
  drupal_goto('taxonomy/term/1');
  // return 'Entered material menu callback';
}

function material_menu_alter(&$items) {
  // return 'Entered Material Menu Alter';
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_taxonomy_page_callback'; 
  return $items;
}

When I select any menu item neither drupal_goto(), or return 'any text' lines redirect the selected path from the menu item.

This question relates to How do I redirect a taxonomy menu item to another path?

I followed the recommendations of Clive and wrote a hook_menu_alter to provide my callback.

function material_menu_taxonomy_page_callback($term) {
  dsm('Entered material menu callback');
}

function material_menu_menu_alter () {
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_menu_taxonomy_page_callback'; 
}

I placed a code line dsm("Altering"); in the callback to see where in the process the callback is being called, but it never shows up.

I am fairly certain that I have the code correct.

  • The hook has the name of the custom module.
  • The callback name is correct.
  • the callback is in the same file as the hook
  • I have turned the module off and then on so that I can be sure that Drupal knows about mymodule_menu_alter
  • And I have flushed the caches.

My assumption is that mymodule_menu_alter()' should change the callback in the menu item array and that the callback will be called each time the menu item is selected. That suggests that my dsm()` message should display at the top of the page requested by the menu.

While Clive's test indicated in his answer worked, my revisions did not. Following Clive's answer recommendations I revised the code as follows.

material.info file contained in modules subdirectory = sites/all/modules/Custom/material

name = Materials  
description = Redefine the path for materials menu
package = CR-Hub
core = 7.x
; Includes
files[] = material.module

material.module file in same subdirectory

function material_taxonomy_page_callback() {
  drupal_goto('taxonomy/term/1');
  // return 'Entered material menu callback';
}

function material_menu_alter(&$items) {
  // return 'Entered Material Menu Alter';
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_taxonomy_page_callback'; 
  return $items;
}

When I select any menu item neither drupal_goto(), or return 'any text' lines redirect the selected path from the menu item.

This question relates to How do I redirect a taxonomy menu item to another path?

I followed the recommendations of Clive and wrote a hook_menu_alter to provide my callback.

function material_menu_taxonomy_page_callback($term) {
  dsm('Entered material menu callback');
}

function material_menu_menu_alter () {
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_menu_taxonomy_page_callback'; 
}

I placed a code line dsm("Altering"); in the callback to see where in the process the callback is being called, but it never shows up.

I am fairly certain that I have the code correct.

  • The hook has the name of the custom module.
  • The callback name is correct.
  • the callback is in the same file as the hook
  • I have turned the module off and then on so that I can be sure that Drupal knows about mymodule_menu_alter
  • And I have flushed the caches.

My assumption is that mymodule_menu_alter()' should change the callback in the menu item array and that the callback will be called each time the menu item is selected. That suggests that my dsm()` message should display at the top of the page requested by the menu.

While Clive's test indicated in his answer worked, my revisions did not. Following Clive's answer recommendations I revised the code as follows.

material.info file contained in modules subdirectory = sites/all/modules/Custom/material

name = Materials  
description = Redefine the path for materials menu
package = CR-Hub
core = 7.x
; Includes
files[] = material.module

material.module file in same subdirectory

function material_taxonomy_page_callback() {
  drupal_goto('taxonomy/term/1');
  // return 'Entered material menu callback';
}

function material_menu_alter(&$items) {
  // return 'Entered Material Menu Alter';
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_taxonomy_page_callback'; 
  return $items;
}

When I select any menu item neither drupal_goto(), or return 'any text' lines redirect the selected path from the menu item.

improved formatting
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Drupal Coding D7 - Menus - My hook_menu_alter &() and page callback doesn'tdon't get triggered

This question relates to the another questionHow do I redirect a taxonomy menu item to another path?

I followed the recommendations of Clive and wrote a hook_menu_alter to provide my callback.

function material_menu_taxonomy_page_callback($term) {
    dsm('Entered material menu callback');
} 

function material_menu_menu_alter () {
 
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_menu_taxonomy_page_callback'; 
}

I placed a code line dsm("Altering");in in the callback to see where in the process the callback is being called, but it never shows up.

I am fairly certain that I have the code correct.

  • The hook has the name of the custom module.
  • The callback name is correct.
  • the callback is in the same file as the hook
  • I have turned the module off and then on so that I can be sure that Drupal knows about mymodule_menu_alter
  • And I have flushed the caches.

My assumption is that `mymodule_menu_alter' should change the callback in the menu item array and that the callback will be called each time the menu item is selected. That suggests that my dsmmymodule_menu_alter()' should change the callback in the menu item array and that the callback will be called each time the menu item is selected. That suggests that my dsm()` message should display at the top of the page requested by the menu.

All suggestions on what might be causing this problem are welcome!

UPDATED CODE: While While Clive's test indicated in his answer worked, my revisions did not. Following Clive's answer recommendations I revised the code as follows:.

material.info file contained in modules subdirectory = sites/all/modules/Custom/material:

material.info file contained in modules subdirectory = sites/all/modules/Custom/material

name = Materials  
description = Redefine the path for materials menu
package = CR-Hub
core = 7.x
; Includes
files[] = material.module
name = Materials  
description = Redefine the path for materials menu
package = CR-Hub
core = 7.x
; Includes
files[] = material.module

material.module file in same subdirectory:

material.module file in same subdirectory

function material_taxonomy_page_callback() {
    drupal_goto('taxonomy/term/1');
    // return 'Entered material menu callback';
} 

function material_menu_alter (&$items) {
  // return 'Entered Material Menu Alter';
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_taxonomy_page_callback'; 
  return $items;
}

When I select any menu item neither the drupal_go_todrupal_goto(), or return 'any text' lines redirect the selected path from the menu item. This problem looks like an error on my part, but

Drupal Coding D7 - Menus - My hook_menu_alter & page callback doesn't get triggered

This question relates to the another question

I followed the recommendations of Clive and wrote a hook_menu_alter to provide my callback.

function material_menu_taxonomy_page_callback($term) {
    dsm('Entered material menu callback');
}
function material_menu_menu_alter () {
 
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_menu_taxonomy_page_callback'; 
}

I placed a code line dsm("Altering");in the callback to see where in the process the callback is being called, but it never shows up.

I am fairly certain that I have the code correct.

  • The hook has the name of the custom module.
  • The callback name is correct.
  • the callback is in the same file as the hook
  • I have turned the module off and then on so that I can be sure that Drupal knows about mymodule_menu_alter
  • And I have flushed the caches.

My assumption is that `mymodule_menu_alter' should change the callback in the menu item array and that the callback will be called each time the menu item is selected. That suggests that my dsm message should display at the top of the page requested by the menu.

All suggestions on what might be causing this problem are welcome!

UPDATED CODE: While Clive's test indicated in his answer worked, my revisions did not. Following Clive's answer recommendations I revised the code as follows:

material.info file contained in modules subdirectory = sites/all/modules/Custom/material:

name = Materials  
description = Redefine the path for materials menu
package = CR-Hub
core = 7.x
; Includes
files[] = material.module

material.module file in same subdirectory:

function material_taxonomy_page_callback() {
    drupal_goto('taxonomy/term/1');
    //return 'Entered material menu callback';
}
function material_menu_alter (&$items) {
 //return 'Entered Material Menu Alter';
 $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_taxonomy_page_callback'; 
  return $items;
}

When I select any menu item neither the drupal_go_to or return 'any text' lines redirect the selected path from the menu item. This problem looks like an error on my part, but

My hook_menu_alter() and page callback don't get triggered

This question relates to How do I redirect a taxonomy menu item to another path?

I followed the recommendations of Clive and wrote a hook_menu_alter to provide my callback.

function material_menu_taxonomy_page_callback($term) {
  dsm('Entered material menu callback');
} 

function material_menu_menu_alter () {
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_menu_taxonomy_page_callback'; 
}

I placed a code line dsm("Altering"); in the callback to see where in the process the callback is being called, but it never shows up.

I am fairly certain that I have the code correct.

  • The hook has the name of the custom module.
  • The callback name is correct.
  • the callback is in the same file as the hook
  • I have turned the module off and then on so that I can be sure that Drupal knows about mymodule_menu_alter
  • And I have flushed the caches.

My assumption is that mymodule_menu_alter()' should change the callback in the menu item array and that the callback will be called each time the menu item is selected. That suggests that my dsm()` message should display at the top of the page requested by the menu.

While Clive's test indicated in his answer worked, my revisions did not. Following Clive's answer recommendations I revised the code as follows.

material.info file contained in modules subdirectory = sites/all/modules/Custom/material

name = Materials  
description = Redefine the path for materials menu
package = CR-Hub
core = 7.x
; Includes
files[] = material.module

material.module file in same subdirectory

function material_taxonomy_page_callback() {
  drupal_goto('taxonomy/term/1');
  // return 'Entered material menu callback';
} 

function material_menu_alter(&$items) {
  // return 'Entered Material Menu Alter';
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_taxonomy_page_callback'; 
  return $items;
}

When I select any menu item neither drupal_goto(), or return 'any text' lines redirect the selected path from the menu item.

added revisions/update
Link
Ashlar
  • 5.1k
  • 6
  • 35
  • 56
edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
Loading
added revisions/update
Source Link
Ashlar
  • 5.1k
  • 6
  • 35
  • 56
Loading
Source Link
Ashlar
  • 5.1k
  • 6
  • 35
  • 56
Loading