[development] Drupal 6.x hook_menu question regarding use of wildcards - Resolved

Ron Parker sysop at scbbs.com
Fri Feb 15 21:33:46 UTC 2008

Yes, thank you.  That answers my question.  I had to re-think my 
approach.  For others who stumble with this as I have, the solution is 
to write your own callbacks customized to process the wildcard value and 
return the value you want.  That's what I did below with 
'agenda_page_title' and '_agenda_list':

function agenda_menu() {
  $items = array();

  $items['node/agenda/list/%node'] = array(
    'title callback' => 'agenda_page_title',
    'title arguments' => array(3, 'List agenda items for: '),
    'page callback' => '_agenda_list',
    'page arguments' => array(3),
    'access callback' => 'user_access',
    'access arguments' => array('view agenda'),
    'type' => MENU_CALLBACK

  return $items;

function _agenda_list($node) {
  return agenda_list($node->nid);

function agenda_page_title($node, $text) {
  $return = $text . $node->title;
  return $return;

Jakob Petsovits wrote:

>On Friday, 15. February 2008, Ron Parker wrote:
>>Chris Johnson wrote:
>>>Um, array(3)->nid is not valid PHP syntax.  Is that what you really meant?
>>That's my question.  I'm trying to figure out if  the wildcard value can
>>be used in such a way.  In my example, the wildcard is %node, which is
>>equal to ($node = node_load(arg(3)).  array(3) is now equal to $node.
>No, array(3) is equal to (in print_r() syntax)
>Array (
>  [0] => 3
>and the menu system just uses this standard PHP array as callback argument in 
>order to get the real number (and from that, the node itself).
>I mean, don't get me wrong - I understand your point, just make sure you 
>recognize that this isn't any special node system syntax but standard PHP.
>  jakob
>__________ NOD32 2880 (20080215) Information __________
>This message was checked by NOD32 antivirus system.

Ron Parker
Software Creations               http://www.scbbs.com
Self-Administration Web Site     http://saw.scbbs.com
SDSS Subscription Mgmt Service   http://sdss.scbbs.com
Central Ave Dance Ensemble       http://www.centralavedance.com
R & B Salsa                      http://www.randbsalsa.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20080215/f0e5501b/attachment-0001.htm 

More information about the development mailing list