GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Tuesday, February 22, 2011

Drupal Page Callback With Arguments

If you want to get the value of  the arguments, please look like this code

 <?php

/**
 * Implements hook_menu()
 */
 
function luna_menu(){
    $items = array();
   
    $items['luna/main'] = array(
        'title' => 'Main Menu',
        'page callback' => 'description',
        'access callback' => TRUE,
    );
   
    $items['luna/po/%'] = array(
        'title' => 'Hello For',
        'page callback' => 'four',
        'page arguments' => array(2),
        'type' => MENU_CALLBACK,
        'access arguments' => array('access arguments page'),
    );
   
    return $items;

}

function description(){
    return array('#markup' => t('The link for this one: '
         .'<a href="@link">About Us</a>',
          array('@link'=>url('luna/po/5'),
          array('absolute'=>TRUE))       ));
}

function four($first){
    return t('You get the info with this number: @number', 
           array('@number'=>$first+10));
}
Share/Bookmark

No comments:

Post a Comment