Skip to main content
added 1436 characters in body
Source Link
Clive
  • 167.9k
  • 19
  • 303
  • 337

You haven't passed $items into the function ;)

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

Without that you're not actually altering anything as $items doesn't exist in a global scope.

You'll also need to clear the caches again once you've made the change.

UPDATE

Working code that I've just verified:

material.info:

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

material.module

function material_taxonomy_page_callback($term) {
  // Calling drupal_goto() here will result in an infinite loop.
  // This is the page callback for pages with a URL like taxonomy/term/1 so
  // there's no need to redirect...you're already where you need to be.
  // This function is used to build up the new page content for the taxonomy page

  // As a test just output the name of the term related to this page.
  return $term->name;
}

function material_menu_alter (&$items) {
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_taxonomy_page_callback'; 

  // You don't need to return anything from this function as $items is passed in by reference...anything you change in that variable will be reflected in the $items var in the calling function.
}

Once installed if I go to any taxonomy page the content region contains just the name of the taxonomy term for that page (using return $term->name). If it's not working for you the only thing I can advise is to clear Drupal's caches, or check what custom/contributed modules you've got installed that might be overriding your code.

You haven't passed $items into the function ;)

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

Without that you're not actually altering anything as $items doesn't exist in a global scope.

You'll also need to clear the caches again once you've made the change.

You haven't passed $items into the function ;)

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

Without that you're not actually altering anything as $items doesn't exist in a global scope.

You'll also need to clear the caches again once you've made the change.

UPDATE

Working code that I've just verified:

material.info:

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

material.module

function material_taxonomy_page_callback($term) {
  // Calling drupal_goto() here will result in an infinite loop.
  // This is the page callback for pages with a URL like taxonomy/term/1 so
  // there's no need to redirect...you're already where you need to be.
  // This function is used to build up the new page content for the taxonomy page

  // As a test just output the name of the term related to this page.
  return $term->name;
}

function material_menu_alter (&$items) {
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_taxonomy_page_callback'; 

  // You don't need to return anything from this function as $items is passed in by reference...anything you change in that variable will be reflected in the $items var in the calling function.
}

Once installed if I go to any taxonomy page the content region contains just the name of the taxonomy term for that page (using return $term->name). If it's not working for you the only thing I can advise is to clear Drupal's caches, or check what custom/contributed modules you've got installed that might be overriding your code.

added 75 characters in body
Source Link
Clive
  • 167.9k
  • 19
  • 303
  • 337

You haven't passed $items into the function ;)

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

Without that you're not actually altering anything as $items doesn't exist in a global scope.

You'll also need to clear the caches again once you've made the change.

You haven't passed $items into the function ;)

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

Without that you're not actually altering anything as $items doesn't exist in a global scope.

You haven't passed $items into the function ;)

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

Without that you're not actually altering anything as $items doesn't exist in a global scope.

You'll also need to clear the caches again once you've made the change.

Source Link
Clive
  • 167.9k
  • 19
  • 303
  • 337

You haven't passed $items into the function ;)

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

Without that you're not actually altering anything as $items doesn't exist in a global scope.