For example, for menus like /node/%node:
when /node/1 is accessed, drupal automatically translates 1 as node_load(1);

I wanted to create something like /path/%student where, when /path/1 is accessed, I could translate 1 into student_load(1);

2 Answers 2


In order to use a placeholder like %student, you need to define a student_load() function in your module, or an enabled module should define such function. Drupal automatically uses that function when the placeholder is used; that is the reason why you should avoid any conflict between the used placeholders and the existing functions.

In your case, you should use code similar to the following one.

function student_menu() {
  $items['path/%student'] = array(
    'page callback' => 'student_page',
    'page arguments' => array(1),
    'access callback' => 'user_access',
    'access arguments' => array('see student page'),

  return $items;

function student_load($id) {
  // Load information from the database; return FALSE in case of error, or when the equivalent database row is not found.

function student_page($student) {
  // $student is the value returned from student_load().
  // …



if you use hook_menu you can use

$items['path/%'] = array(
        'title' => '',
        'page callback' => 'my_fn',
        'page arguments' => array(1),
        'weight' => 0,

function my_fn($student_id){
   $node = node_load($student_id);
   return $node->title;
  • Hi, thanks! But this is not what I am looking for. I want the function to automatically run for when %student is included in the path.
    – Bibokid
    Aug 30, 2013 at 18:33
  • I think If your link path/1 it will display the title of node number 1,or can you explain in more details
    – Ahmed
    Aug 30, 2013 at 18:38

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.