3

I'm reading in Apress' Definitive guide to Drupal 7 and I'm trying to understand what they're saying. For those who have the book, on page 404 paragraph it says - and I quote - "Every path ultimately matches up to a menu item with a page callback function that has chief responsibility for displaying the page at that path."

But aren't there paths that don't match up to menu items? Or are menu items in this content different things to begin with? And menu items containing functions? How do menu items contain functions?

Maybe The Definitive Guide is a confusing book and there are better resources for understanding how module development works? (I've searched the web for many resources already and they've all been just as confusing as Apress's)

2 Answers 2

3

I have the book, but page 404 does not include the quote in mine (the beginning paragraph is "The switch statement does...", so I cannot interpret the exact context of the quote. In general, every page is assigned a path and drupal determines the display from its 'menu' of path options. Think of the displayed menus as a subset of the available options in drupal's list.

Drupal stores information about each site in the database and callback functions are associated with the each master menu option. When a URL is requested, it queries the database, finds the associated function and executes it.

I found parts of 'The Definitive Guide...' confusing to begin with too, but it is actually pretty good overview and quite useful. The problem is that Drupal is very large and a complex system to get your head around at first. The learning curve seems enormous at first (I know), but soon parts begin to fall into place and you begin to "GET IT".

This site is a great place to expand your understanding and begin to put it together. Your question was well written (clear) and there are plenty of people here to answer (although traffic is slow this week with the holidays).

1
  • Hey thanks very much for your feedback as I'm always preoccupied with wether my question is clear enough (a lot of times it isn't). It was actually the pdf reader that says 404. With me, the actual page is 394 under "HOW DRUPAL USES HOOKS TO DISPLAY HELP TEXT ON A PAGE" 3rd paragraph. Now I'm more confident that I can ask about things that confuse me in the book(s).
    – Immers
    Commented Jan 11, 2012 at 14:39
3

The part you quoted is at page 392, in a section titled, "Drupal Turning Paths into Pages: hook_menu()."
What the book reports is exact, if you exclude the path to files existing on the server, such as update.php, or cron.php; apart those paths, in Drupal every path is defined in the implementation of hook_menu().

The term "menu item" is not referring to the menu items you can add to the menus using the user interface, as those don't generate an internal path; if I set a link to Drupal.org in the main menu for my site, that link is not associated with an internal path such as http://example.com/drupal.org.

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.