For example, here's a snippet form the Comments Module (comment.module):

function comment_menu() {
  $items['comment/%'] = array(
    'title' => 'Comment permalink',
    'page callback' => 'comment_permalink',
    'page arguments' => array(1),
    'access arguments' => array('access comments'),
  $items['comment/reply/%node'] = array(
    'title' => 'Add new comment',
    'page callback' => 'comment_reply',
    'page arguments' => array(2),
    'access callback' => 'node_access',
    'access arguments' => array('view', 2),
    'file' => 'comment.pages.inc',

  return $items;

How can I override $items['comment/%'] with $items['comment/reply/%node'], without hacking core.

In other words, I need example.com/comment/[cid] to look exactly like example.com/comment/reply/[nid]/[cid]?

2 Answers 2


Yes, you should use hook_menu_alter Create new module and add hook_menu_alter

function my_module_menu_alter(&$items) {
    // Unset core path
    $items['your/pass/here/%node'] = array(
        'title' => 'Add new comment',

But link "comment/reply/%nid/%cid" is used by Drupal for replies to other comments (where %nid - node id and %cid - comment id you are replying to). Use another path.

  • How safe is it to unset the $item? I'm asking, because in some instances you're preferred to use hide(), etc... Commented Oct 10, 2012 at 0:57
  • well. really all information about menu callbacks are stored in DB - table "menu_router". This table is updated when you are flushing cache. While flushing - drupal reads all hook_menu and hook_menu_alter functions. So after unset - just you will get row with such callback in this table.
    – Gaydabura
    Commented Oct 10, 2012 at 1:01

You can always use hook_menu_alter and pass the same page callback and arguments.

  • Is there a function that can do that in template.php? Commented Oct 9, 2012 at 20:21
  • menu alter should be implemented in a module. I personally am not aware of a way to override the menu at the template level.
    – junedkazi
    Commented Oct 9, 2012 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.