API page: http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...

Describe the problem you have found:

I can't make sense of this paragraph describing how hook_menu() works:

Note that if a page or theme callback function has an argument list array, these arguments will be passed first to the function, followed by any any arguments generated by optional path arguments as described above.

Not sure what these phrases are supposed to mean or refer to:

  • "has an argument list array"
  • "passed first to the function"
  • "any any"
  • "as described above"

Bottom line, I don't know what this paragraph is supposed to convey. Rewording this and adding a very short example would help.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Title: Documentation problem with hook_menu » hook_menu doc has some confusing text in it

I see your confusion.

What it's trying to say is that if you have something like this:

 $items['abc/def'] = array(
      'page callback' => 'mymodule_abc_view',
      'page arguments' => array(1, 'foo'),
    );

And you visit path abc/def/ghi/jkl

the function mymodule_abc_view() will get arguments: 'def', 'foo' [from the 'page arguments'], followed by 'ghi', 'jkl' [from the additional path components, as described above that paragraph].

Agreed that this paragraph needs a rewrite, possibly with this example, to make it clearer.

mr.baileys’s picture

Status: Active » Needs review
FileSize
1.44 KB

Here's a suggested fix.

mr.baileys’s picture

Previous patch was incomplete...

Status: Needs review » Needs work

The last submitted patch, 1182970-menu-optional-args.patch, failed testing.

mr.baileys’s picture

Status: Needs work » Needs review
FileSize
1.75 KB

Looks like my local copy was outdated, re-rolled against a fresh copy...

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

I like it! A good concrete example is worth a thousand explanations, to paraphrase the usual picture's value statement.

8.x/7.x please... and then this is probably also worth porting to 6.x, don't you think? Works the same there. If we port to 6.x, we have to move this to the Documentation project, component "api doc files", and mark "patch/to be ported" -- the hook docs are there for 6.x.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x and 7.x. Thanks!

jhodgdon’s picture

Since the D6 port is in the Documentation project, I filed it as a separate issue. I didn't want to move this one out of Drupal core.
#1201380: hook_menu doc has some confusing text in it

Automatically closed -- issue fixed for 2 weeks with no activity.