I'm working on a custom module, and I'm building menu items using entries in a database. These are being cached, and the database is only really updated about once a month.

I'm having an issue getting wildcards to work with this menu.

Here's my menu structure that WORKS:

$dbconn = dbConnect();
$query = "SELECT TOP 3 id, title FROM table";
$q = mssql_query($query, $dbconn);
while($r = mssql_fetch_assoc($q)) {
    $title = $r['title'];
    $items[$title] = array(
        'title' => $r['title'],
        'description' => 'Page for ' . $r['title'],
        'page callback' => 'programs_page',
        'access callback' => TRUE,
        'type' => MENU_NORMAL_ITEM,

But the moment I add the % into the array key, the menu items just disappear, like so:

$items[$title . "/%"];

Any suggestions on why drupal is tripping up on this? Even if I tack the ."/%" onto the $title variable, it doesn't work.

  • May you provide the full code of the function?
    – apaderno
    Apr 6, 2011 at 14:18

1 Answer 1


There is no need to add wilcard placeholders after your last path element. Anything tacked onto the end of the URL will be passed to the callback as arguments automatically.

If the example you give above, if someone goes to $title/arbitrary/arguments, then 'arbitrary' and 'arguments' will be passed as arguments to your page callback:

programs_page('arbitrary', 'arguments');

If you want arguments in the middle of your path, you can specify them with a % sign, or if you would like to automatically load and pass an object to your page callback, you can use wildcard loaders.

  • The User module uses a path like user/reset/%/%/%; using a wildcard at the end of a path is not forbidden.
    – apaderno
    Apr 6, 2011 at 14:17
  • Alright, so when I declare the programs_page function, I just have to do: function programs_page($arg1, $arg2, $arg3, ...) so I can reference them inside my function, correct?
    – oranges13
    Apr 6, 2011 at 14:22
  • 1
    @oraanges13, yes that's right. They will be passed regardless, so you can use func_get_args() to check for arguments too. That's how functions like db_query work.
    – cam8001
    Apr 7, 2011 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.