It seems to me that the "page_example_menu" text is not right, since it's supposed to be documenting the actual "page_example_menu" code, but it doesn't. For example, it talks about "baz" which is not in the actual code. To use "baz" might be OK as an example, but this documentation is trying to document the actual "page_example" code, so should talk about the functions used there. As it is, it's very confusing to me as a person trying to learn how to do modules. Unfortunately I'm not best placed to rewrite it.

I think, for example, the text should say something more like:

 * If the user accesses http://example.com/?q=examples/page_example/arguments/1/2, the menu system
 * will first look for:
 *     examples/page_example/arguments/1/2. 
 * Not finding a match, it will look for:
 *     examples/page_example/arguments/1/%. 
 * Again not finding a match, it will look for: 
 *     examples/page_example/arguments/%/2. 
 * Yet again not finding a match, it will look for:
 *     example/arguments/%/%. 
 * This time it finds a match, and so will execute page_example_arguments(1, 2). Note the parameters
 * being passed; this is a very useful technique.

Note, if this is correct there are I think other similar changes to be made.

Comments

jhodgdon’s picture

Project: Drupal core » Examples for Developers
Version: 6.x-dev » 6.x-1.x-dev
Component: documentation » Page Example

Moving to correct issue queue for triage...

pfrenssen’s picture

The comments inside the page_example_menu() function need to be updated as well.

Here's an updated version:

  // By using the MENU_CALLBACK type, we can register the callback for this
  // path but do not have the item show up in the menu; the admin is not allowed
  // to enable the item in the menu, either.
  //
  // Notice that the 'page arguments' is an array of numbers. These will be
  // replaced with the corresponding parts of the menu path. In this case a 0
  // would be replaced by 'examples', a 1 by 'page_example', a 2 by 'arguments'
  // and likewise 3 and 4 will be replaced by what ever the user provides. We
  // will passed these last two as arguments to the page_example_arguments()
  // function.
rfay’s picture

Patches are appreciated!

pfrenssen’s picture

Status: Active » Needs review
StatusFileSize
new4.93 KB

I have incorporated drupalshrek's suggestion and #2 in this patch, and gave the whole documentation for this function an overhaul.

Status: Needs review » Needs work

The last submitted patch, 903050-4.patch, failed testing.

pfrenssen’s picture

Status: Needs work » Needs review

#4: 903050-4.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 903050-4.patch, failed testing.

rfay’s picture

Status: Needs work » Needs review

The problem with tests was resolved so now this can be reviewed properly.

rfay’s picture

StatusFileSize
new4.93 KB

OK, slight fixups and I think this is good to go.

rfay’s picture

Status: Needs review » Fixed

D6 testing isn't working, so I just committed this: http://drupal.org/cvs?commit=463782

Thanks so much, @pfrenssen

Status: Fixed » Closed (fixed)

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