Working on a hook_menu() function that i got working fine with the following code:
function mymodule_menu(){
$items = array();
$items['assessment/%'] = array(
'page callback' => 'mymodule_assessment_page',
'page arguments' => 'array(1),
'access arguments' => array('access content'),
'file' => 'pages/mymodule.assessment.inc',
'type' => MENU_CALLBACK,
);
}
However when i try the following (after clearing cache etc) i get a page not found error.
function mymodule_menu(){
$items = array();
$items['%/assessment'] = array(
'page callback' => 'mymodule_assessment_page',
'page arguments' => 'array(0),
'access arguments' => array('access content'),
'file' => 'pages/mymodule.assessment.inc',
'type' => MENU_CALLBACK,
);
}
Ive searched google and i see no mention of not being able to put a path wildcard at the front of the url.
Can anyone notice anything im doing wrong here? Or is it a case of drupal not supporting paths beginning with wildcards.
Anyhelp will be massively appreciated, thanks!
The problem is that you use the wildcard as the first component. If you look at the documentation for hook_menu()
you will see the following:
Wildcards in Paths Simple Wildcards
Wildcards within paths also work with integer substitution. For example, your module could register path 'my-module/%/edit':
$items['my-module/%/edit'] = array( 'page callback' => 'mymodule_abc_edit', 'page arguments' => array(1), );
When path 'my-module/foo/edit' is requested, integer 1 will be replaced with 'foo' and passed to the callback function. Note that wildcards may not be used as the first component.