Reputation: 71
How can I pass in a parameter (eg: SKU12345) into a Drupal module. Here is what I have so far...
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;
}
Upvotes: 3
Views: 2747
Reputation: 19441
Your basic approach looks OK, but you'll need some minor adjustments:
'page arguments' => array(2)
- (the parameter count is zero based)$items['my_module/sku/%']
for starters - the %mySKU
notation would try to use a 'wildcard loader function', hence needing an additional callback function. (depending on your scenario, you might want to use this mechanism later on, but for now it would probably be distractive)Upvotes: 3