1

I have a module where I try to catch an url to use a specific function.

function my_module_menu(){
    $items['beneficiaire/commande'] = array(
        'page callback' => 'test_view',
    );
    return $items;
}

function test_view(){
    var_dump('test_view');
    exit();
}

Unfortunately, when I call beneficiaire/commande nothing append. I know Drupal go through this hook because when I do

function my_module_menu(){
    die('poc');
}

I see 'poc'.

5
  • Always read the docs before writing code - your router item is missing several required properties. The duplicate has full details
    – Clive
    Commented Dec 4, 2014 at 9:21
  • Excuse me @Clive but i've read the doc and my code is a copy/paste from api.drupal.org/api/drupal/modules!system!system.api.php/… I have just updated the url and the function
    – billyJoe
    Commented Dec 4, 2014 at 9:32
  • That example is just a partial, if you read everything on that page, and the duplicate, you'll understand what you've missed (access callback/arguments for example)
    – Clive
    Commented Dec 4, 2014 at 9:36
  • nothing more even when I had the required title, and an access callback. I Will look for help elsewhere.
    – billyJoe
    Commented Dec 4, 2014 at 9:58
  • Not sure what to tell you - the documentation isn't wrong :) Letharion's write up in the duplicate is also correct, and probably easier to understand than the full documentation if you're new to developing for Drupal. The reason this is closed as a duplicate is because all of the information to answer your question is already covered in the other; as a Q+A site (not support forum), that's normal procedure here
    – Clive
    Commented Dec 4, 2014 at 10:01

1 Answer 1

0

Your callback function is wrong:

function my_module_menu(){
  $items['beneficiaire/commande'] = array(
    'page callback' => 'commande_view',
  );
  return $items;
}

function commande_view(){
  var_dump('test_view');
  exit();
}

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