Adding contextual menu links and using menu autoloaders

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:08
    In this final chapter about implementing Drupal's hook_menu,
  • 0:11
    we're going to take a look at 2 more things that we can do when creating new menu items.
  • 0:16
    First, we're going to take a look at how we can add a link
  • 0:20
    to the contextual links menu for all the nodes on our site.
  • 0:24
    Now the link's going to be this one where it says Magic.
  • 0:26
    When you click on it, you'll be taken to a page
  • 0:29
    that says this Sample Page has been Magicified and it shows the text of the page upside down.
  • 0:36
    In addition to adding contextual links,
  • 0:39
    we're also going to take a look at using a system
  • 0:41
    that Drupal refers to as autoloaders,

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: 
Log in or sign up to download companion files.
Additional resources: