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;
}
Your basic approach looks OK, but you'll need some minor adjustments:
- You'd need to use
'page arguments' => array(2)
- (the parameter count is zero based) - You should use
$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) - If you want to adjust the title according to the passed in name, you can not use the wildcard directly, you'll need to use a 'title callback'/'title arguments' combination (same way as with the page callback and argument parameters).
精彩评论