By Bouke on
Hi,
I was wondering if it's possible to pass different arguments to a page. e.g my hook_menu looks like this:
$items['node/test/%arg1||%arg2'] = array(
'title' => 'test',
'load arguments' => array(2), /
'page callback' => 'drupal_test_page',
'page arguments' => array(test stuff),
'type' => MENU_CALLBACK,
);
and my test page looks like this:
function drupal_test_page($arg1 = NULL, $arg2 = NULL){
if(isset($arg1)){
//do stuff
}elseif(isset(arg2)){
//do some other stuff
}
}
I understand the code above won't acutally work but I would be really interested in any methods to achieve the same results. If it's unclear what I mean just ask and I'll try to answer asap.
Thanks in advance,
Bouke
Comments
Its better to use two arguments
Its better to use two arguments.
First argument accepts the type(key) and second argument accepts the value.
Or you can try out some other solutions too, but not the one you have written.
Allright, thanks a lot. Seems
Allright, thanks a lot. Seems like a smart solution. I thought about using two arguments but didn't know how to do it if only one is used. Smart idea to take one as argument and the other as value!
Tashicoder is correct. The
Tashicoder is correct. The logic has to happen in the callback function, it won't happen in hook_menu().
Contact me to contract me for D7 -> D10/11 migrations.
Or anything really. I'm friendly, and open to work or conversation.