This chapter goes through the process of passing a wildcard variable to a function via an argument from the URL. It creates a MENU_LOCAL_TASK tab on the node which inverts the text to display upside down. It uses a page callback function that is included within a separate file in order to save on how much memory is used.
In this video you'll learn how to use api.drupal.org the canonical source for information about Drupal's hooks, APIs, and code documentation in order to find out information about implementing a particular hook, making use of a particular function or library of functions, and even gaining a better understanding of some of the big picture concepts behind Drupal's code and APIs.
Walks through some of the basics elements that are required and common for all Drupal modules. Then we create a simple demo module to see how it works.
This chapter describes how Drupal modules are able respond to specific events through the hook system. A couple of example hooks are implemented in order to see how this process works. This video builds on the demo module we created in the previous chapter.
In this video Joe Shindelar provides a quick overview of the minimum set of tools you'll need in order to get started with module development. Some kind of web server to host your development site on, an editor that allows you to edit PHP files (preferably one with syntax highlighting), a MySQL client, and Drush. Learn about how these essential tools fit in the module developers tool belt and then download and install a bare bones copy of Drupal to start tinkering with.
Provides a overview presentation for how Drupal's menu system takes care of incoming requests via the index.php. Then it walks through the process of implementing a simple module that hooks into Drupal's menu system at the path of /magic.
It then executes a page callback function of menu_magic_basic(),
which outputs some simple markup text.
Additional resources
Drupal 7 co-maintainer Angie Byron gives a overview of some of the new Drupal 7 features, themes and user interface. She is joined by Nate Haug, Jeff Robbins, Jeff Eaton and Kent Bye who also provide a lot of insights through dynamic conversation, questions, and a fast-paced, hands-on tour of the major highlights of the new Drupal 7 release.
This screencast gives miscellaneous tips when writing Rules plugins, such as:
- Some words on declaring new data types for Rules
- How to restrict access to plugins
- How to form alter plugin configuration forms
- How to provide additional form validation
- How to use the "base" property to provide a non-default callback function
- How to invoke events programmatically with all arguments in a single array
- How to use drupal_static() to share variables/values with other parts of Drupal
This screencast shows how to add parameters to your actions, for example to allow site builders to select which user object an action should work with.
This screencast shows:
- How to declare that an action provides new data objects to Rules
- How to actually send the created data to Rules
- How to save parameters that are manipulated by the action (but not created by it)
The example used creates an action that returns the number of hits in a selected view.
This screencast shows how to:
- Use text as an input parameter for an action
- Provide your action configuration with a customized select list
- Restrict input for a parameter to "direct input" (and not data selection)
This screencast shows how to create a condition plugin for Rules:
- How to declare new conditions for Rules
- How to provide the condition callbacks with parameters to act on
- The big similarities and the few differences between actions and conditions
In the example, a condition is built to check which view type a provided view has.
This screencast shows how to:
- Invoke a Rules event
- Send parameter data to a Rules event
This is shown by an event triggered every time a view is being rendered, sending the name of the view as a parameter.
This screencast shows how to:
- Declare a Rules event
- Declare the data provided by the event
- Use that data in a rule
The example used creates an event "View is being rendered", passing along information about which view is being used.
This video shows the basic syntax for creating form dependencies with the states system. For a more information about the states system, then be sure to check out JavaScript form dependencies with the States System.
Note: There is a typo in the code used in this video. The function form_fun_states_form()
is missing a parameter, and should be: function form_fun_states_form($form, &$form_state)
.
When writing code for the web it is very important that you pay attention to security. Drupal provides many tools to help you out and in this presentation we'll look at what those are and how to make sure you use them properly.
Additional resources
In this chapter we learn how to get data out of the database and display it. The example walks through writing a module that creates a page that displays how many nodes are published and unpublished for each content type in our site. We use the db_select() function to accomplish this.
In this chapter we learn about changing the definition of a database table after it has already been installed. This example expands on the previous chapters by adding a new field to the table to collect the date a user last visited a node. We learn more about hook_update_N() as well as db_add_field().
In this chapter we learn other ways to interact with our database beyond the simple db_select() query from the earlier video. This example walks through writing a module that that saves and displays data about how many times a user has visited a specific page. We learn about db_select(), db_insert(), db_update(), db_merge(), db_delete() and introduce the concept of "get and set" helper functions.
In this chapter we learn how to create a new database table. This example walks through creating a module that defines the the properties of our new table and also programatically creating that table. We learn about hook_schema() and hook_update_N() in our module's install file.
Trainers note: This video starts out with a module that implements hook_node_view() and stores data about views in the $_SESSION variable. It also states that we built this earlier in the series. However, that's not true. We did talk about hook_node_view() in https://drupalize.me/videos/event-driven-hook-system, but we never actually wrote the $_SESSION handling part. So, if you're following along and want the same sample code we start with make sure you download the code attached to this node.