0
votes

I am using drupal 7. I have a link which goes to href="/mod/filter/1"

 <a href="/mod/filter/1">X</a>

and i have a a hook_menu

 function mod_menu () {
    $menu = array(
                    'mod/filter/%' => array (
                                    "title" => "Bare HTML for use in ajax.",
                                    "page callback" => "mod_remove_filter_function",
                                    "page arguments" => array(1),
                                    "type" => MENU_CALLBACK,
                    )
    );

    return $menu;
 }

Then the callback function

 function mod_remove_filter_function($arg){
    dsm('call back filter');
    drupal_goto('/res/search');
 }

To me this should work, It is the first time i've used the menu hook but this looks like it should work according to the documentation given.

Any ideas why is doesn't work?

2

2 Answers

1
votes
function mod_menu () {
    $menu = array(
                'mod/filter/%' => array (
                                "title" => "Bare HTML for use in ajax.",
                                "page callback" => "mod_remove_filter_function",
                                "page arguments" => array(1),
                                "type" => MENU_CALLBACK,
                )
  );

  return $menu;
  }

hook is workds perfect. problem might be in the callback function dsm function requires devel module and if you are using the drupal_goto('/res/search'); check for the "/res/search" path first .

:) 

here is how I use hook_menu in custom modules.

$menu['mod/filter/%'] = array(
        'title'=>t('look this is title'),
                    'page callback' => 'mod_remove_filter_function',
        'access callback' => 'user_access',
        'access arguments' => array('access_contents'),
        'type' => MENU_NORMAL_ITEM,
    );
0
votes

Do not use t() function in your menu item. By defualt drupal will pass the title string into the function t(). You can change that behavior by setting a new 'title callback' in your menu item array

See hook_menu book from drupal.org