In hook_menu() there are ten entries, but some of them are shortcuts to the same place, and this is achieved using a page callback which just calls drupal_goto. This initially obscured the actual url of the menu item. For clarity, if an item has a page callback which only does a drupal_goto() I think the menu item should do the drupal_goto directly. It is then clearer when reading the hook_menu function what exactly each link does and what the final url will be.

For example:

  // Tab for Admins to have quick access back to main weblinks page. 
  $items['admin/config/content/weblinks/links'] = array(
    'title' => 'Links page',
    'page callback' => '_weblinks_settings',
    'access arguments' => array('access web links'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 10,
    );

can be replaced with

  // Tab for Admins to have quick access back to main weblinks page. 
  $items['admin/config/content/weblinks/links'] = array(
    'title' => 'Links page',
    'page callback' => 'drupal_goto',
    'page arguments' => array('weblinks'),
    'access arguments' => array('access web links'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 10,
    );

and we can delete the function

function _weblinks_settings() {
  drupal_goto('admin/config/content/weblinks');
}

Comments

jonathan1055’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1.77 KB

Patch for all three of these.

gstegemann’s picture

Patch applied and committed.

Please note: after applying this patch the cache has to be cleared.

gstegemann’s picture

Status: Needs review » Fixed
jonathan1055’s picture

Thanks Gerhard. I presume you were happy with my explanation of why I think it is clearer to have the drupal_goto and final url within the hook_menu()

If you use the devel module, they have a nice 'rebuild_menus' link which calls the necessary menu_rebuild()

gstegemann’s picture

Yes, sure. But the implementation of hook_menu was basically taken from the D6 version. I really didn't spent much time analyzing the code in more detail and for any further optimizations.

Thanks for your hint regarding the 'rebuild_menus' link. But on sites w/o the devel module clearing the cache works as well.

nancydru’s picture

And the D6 version may have been rushed and never revisited.

I recommend the Admin_Menu module which also has cache clearing functions.

gstegemann’s picture

Quite possible.

In fact I have used the Admin module cache clearing function.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.