. How to use placehoders to pass arguments in the middle of a path
2. So for example, when you go to "node slash and then the node id slash edit", this is an example of where we know the beginning and the end but not necessarily the middle. And the way that we register a function to handle this is just a little bit different than we handle arguments. Go ahead and jump to your module directory and what we're going to do is open up step six which is called "placeholders".
3. And we're going to open this up. Go ahead and copy all of the code and then paste it over the current code in your "pages dot module" file. And save it.
4. Ok, I'm going to scroll up to our "hook_menu" function here. Right here. And at the bottom we've added one additional item called "pages slash and then there's a wildcard and then slash placeholder".
5. So when we say wildcard in Drupal, most of the time we're talking about this percentage sign here. And what it means is that this is a variable item. We don't know what's going to be here.
6. The way that we register a placeholder inside of a menu function has two parts. First of all we use this placeholder inside of the path so where we would expect something variable we would add it as a wildcard and then the second part is in the "page arguments" parameter in the menu item. We're going to pass it an array.
7. And any numbers that we pass through this array will get assigned values based on it's location inside the path, starting with the number zero. So the first argument will be a zero and that would be "pages" but the second one, which would be number one, is our wildcard. So we're passing it an array and the number will automatically get loaded with that wildcard item.
8. This means that if we wanted to pass additional placeholders we could do so and simply add the number of that placeholder inside of this array. Now this "page arguments" parameter is a list of parameters that are going to get passed.
In our most popular collection, we build a strong foundation for developing in Drupal, covering the most commonly used APIs, building practical and interesting modules, and covering a tremendous amount of ground. Just a few of the topics we cover:
- How to build and manipulate forms with the Form API
- How to write jQuery to build a rich interface
- How to programmatically manipulate content and user data