Adding Contextual Menu Links and Using Menu Autoloaders

Loading...

This chapter walks through the process of adding links to the contextual drop-down widgets new in Drupal 7. It also shows how using menu autoloaders can help simplify the code that you write in your page callback function since you won't have to do extra checking on the data.

As a note, if you are wondering why we started our function with an underscore (_), naming functions with an underscore in front of the name is a common convention in Drupal that sort of implies that "this function is for internal use by this module only" and shouldn't be called by itself. It's also a nice way to ensure that your internal functions are not colliding with the namespace of a hook or another module. Here's a good blog post about naming things.

Downloads: 
Sign in or sign up to download companion files.
Additional resources: 

Average review

5
Average: 5 (1 vote)

Reviews

5

I love how Joe starts off with using the "%" wildcard to explain the process that happens when it's called in a function and then goes step by step with what Drupal listens to and can do with it. He always focuses on important details such as documenting before he writes new code, takes the latest render able output (even showing us how to find it using Devel as an example), explains what is best practice for Drupal PHP writing, and then at the end of writing a function perfectly goes back and tells us how Drupal already provides us some defaults and then simplifies the code we were writing in the lesson and easily allows me to understand the concept of what happens in a raw "%" wildcard and a predefined Drupal "%node," "%user," %term" that is part of the "(node/term/user, etc)_load." It was essential for me to have some background on the story line for the function we were writing so thank you Joe!!!