Passing parameters to the Drupal module

How to pass a parameter (for example: SKU12345) to the Drupal module. Here is what I still have ...

URL: / my_module / sku / SKU12345

  $items['my_module/sku/%mySKU'] = array(
    'title' => 'Information for SKU %',               // include SKU in title 
    'page callback' => 'my_module_with_parm',
 //'page arguments' => array('my_function_name', 3),   // 3rd parameter?
 'page arguments' => array(3),   // 3rd parameter?
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
    'file' => 'my_module.pages.inc',
  );


//function my_function_name()
//{}

function my_module_with_parm($my_parm) {

  $output = $my_parm;
  return $output;
}
+3
source share
1 answer

Your basic approach looks fine, but you will need minor adjustments:

  • You need to use 'page arguments' => array(2)- (the number of parameters is zero)
  • $items['my_module/sku/%'] - %mySKU " " , . ( , , , , , ).
  • , , "title callback" / "title arguments" ( , ).
+3

Source: https://habr.com/ru/post/1751051/


All Articles