Drupal 7 Module Development
4.5 (33 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
295 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Drupal 7 Module Development to your Wishlist.

Add to Wishlist

Drupal 7 Module Development

A complete guide to practically building a fully functional custom Drupal 7 module from scratch.
4.5 (33 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
295 students enrolled
Created by Packt Publishing
Last updated 12/2014
English
Current price: $10 Original price: $85 Discount: 88% off
5 hours left at this price!
30-Day Money-Back Guarantee
Includes:
  • 3 hours on-demand video
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
What Will I Learn?
  • Build a .info and .module file to set up your module.
  • Write hook_menu and hook_permissions functions
  • Set up an admin settings form and use hook_form_alter
  • Create database tables using hook_schema and .install files
  • Write node hooks and database queries
  • Create a custom block via your module
  • Theme the block and write CSS to style it
  • Use t function and other sanitization functions to secure your module
  • Use and create custom Drupal variables
  • Explore the research functions in the Drupal API
View Curriculum
Requirements
  • You should have a familiarity with Drupal but no experience with programming Drupal custom modules or PHP is required to follow this course.
  • All videos include hands-on practical examples to follow along with. This course is geared towards beginners in Drupal development and anyone who wants to learn to use Drupal code.
Description

In this course you will learn to build a Drupal custom module by completing short tasks and ultimately weave the tasks together to get a completed and fully functional module. Drupal 7 Module Development introduces you to module development by understanding the essential hooks and functions, building tables and querying the Drupal database, exploring module security, performance and how our module interacts with Drupal core and contributed modules. Each video walks you through essential Drupal functions and demonstrates how to use these functions in a module that we build hands-on together Drupal 7 Module Development starts by showing you how to set up your local development environment to support custom module development. You will learn how to use the best tools and configure them. Next you will learn to configure a Feeds importer to import content into your site that you will then leverage with your custom module and write a menu callback using hook_menu and hook_permissions. We will then look at the form API and write a hook_form_alter function and create a .install file and build a db schema function to create a table in our database Finally we create a block using our module and theme the block. We end the course by reviewing our module from a security and performance standpoint. From the local development to the review of security we build a custom module step-by-step throughout the course’s short videos.

About the Author

Trevor James is a Drupal developer residing in Middletown, MD, USA. Trevor has been using Drupal intensively since 2007 and designing websites for over 15 years using a combination of HTML, CSS, ColdFusion, PHP, jQuery, and JavaScript.

Trevor's focus is on building Drupal-based web applications and portals for education, non-profit, and medical systems, and small business environments. He is interested in the best methods of integrating web services with Drupal sites, optimizing Drupal sites' performance, and using Drupal content types, Views, Panels, and other contributed modules to develop front-end interfaces that support data intensive websites.

He loves teaching people about Drupal and how to use this excellent open source content management framework.

Who is the target audience?
  • This course is perfect for any Drupal user who is just starting to explore Drupal core and contributed modules. If you’ve used some contributed modules you can now turn to learning how to write your own custom Drupal 7 module.
Students Who Viewed This Course Also Viewed
Curriculum For This Course
43 Lectures
03:06:01
+
Installing Drupal for Custom Module Development
5 Lectures 22:03

We need to set up a local development environment for our Drupal programming. Install an Apache Web server locally with PHP and MySQL to support a Drupal 7 website.

Installing and Configuring MAMP
04:14

Install a local integrated development environment that we'll use to code our custom Drupal module.

Installing and Configuring Aptana Studio editor
04:54

Set up a local Drupal 7 website install. Download Drupal 7.14 and install Drupal core.

Installing and Configuring Drupal
05:07

Enable a few core Drupal 7 modules and inspect the /modules directory.

Drupal Modules
03:30

Learn how to set up folders to hold the contributed and custom Drupal module we'll be working on in this video series.

Setting Up custom and contrib Modules Directory
04:18
+
Introducing the Custom Facebook Feed Module
9 Lectures 38:48

We've installed the Feeds module but we need to install the required and dependent modules so we can enable all of the Feeds suite of modules and configure a Feeds importer. We install the Ctools and Job Scheduler modules; as well as the Views, Devel and Feeds Tamper modules. We also load our Facebook page's RSS feed and get the RSS feed URL to use in our import process.

Preparing to Import Feeds
04:05

To import our RSS feed we need to clone an existing Feeds importer that handles XML and RSS feed parsing. Once the importer is created we can run our import by adding the RSS feed. The import will create nodes on our site using the Feeds Item content type.

Creating the Feeds Importer
04:55

Our PHP memory limit is at 32M but we'll need more memory to run the Feeds, Devel, and Feeds Tamper modules and run our import. We raise the memory limit to 96M. We also set up a tamper on our importer to change importer characters to specific apostrophes.

PHP Settings and Feeds Tamper
04:38

We need to be comfortable using PHP when we code our module so that we can point out some PHP resources for Drupal developers. We also look at some documentation on Drupal coding standards and inspect some contrib module code to see how these standards are applied.

PHP Intro and Drupal Coding Standards
04:23

The first custom module file we need to create is the .info file. We create the .info file and write some code into it. We also create a .module file. We then enable our new custom module.

Creating the .info File
05:06

We'll add some PHP code and comments to our module file and practice Drupal coding standards for commenting.

Creating the .module File
03:14

We need to know what functions are available to us when we write our module code so that we can review the api.drupal.org website.

Understanding the Drupal API
03:56

We need to use the Devel module so we can have access to tools and utilities for Drupal developers.

Using the Devel Module
04:45

How can we access specific content type field names and other data about our nodes? Using the Devel module enables us to inspect all of our page elements.

Using Devel Module to Inspect Page Variables
03:46
+
Menu Callbacks and Permissions
4 Lectures 17:11

Now that we have our .info file and .module file created we need to start writing functions for our module. The first function we'll write is called hook_menu. This function will allow us to create an array(s) for each of our module's admin screen menu items. This way our module's users can configure the module via the Drupal admin interface.

Using the hook_menu Function
03:29

If you do not see your hook_menu function working yet you need to flush the Drupal cache.

Caching
03:30

Now that we have a function in our module and the module is working, we need to add some permissions so our roles can use the module. We do this by writing a hook_permission function.

Using the hook_permission Function
05:33

Now we need to add the admin.inc file to our module folder so we can start writing our menu callback functionality including the drupal_get_form function we added earlier to our .module file.

Adding the admin.inc File to Our Module
04:39
+
The Form API
5 Lectures 18:10

We have a blank admin.inc file that we need to add our admin_settings_form function to in order to build out the admin settings form for our module. We add the function to our admin.inc file and all form elements including a text field and checkbox series to it.

Using the system_settings_form
03:06

We've added a text field to our admin form. Now we expand our form by adding a checkbox series to allow for choosing the content types that our module will integrate with

Using the admin_settings_form and Checkboxes
02:59

We review how our module is setting and getting variables defined on our admin settings form.

Creating and Using Drupal Variables
03:10

Our text field needs a couple of validation handlers. We write these using hook_validate.

Using the hook_validate Function
02:56

We need to allow our admins to choose specific nodes to show in the Facebook Feed Block. To do this we need to alter the content type edit form to add an admin fieldset for our checkbox.

Using the hook_form_alter Function
05:59
+
Connecting with the Database
5 Lectures 25:55

We are collecting data via our hook_form_alter on our node edit form but currently we have no way to save the data we collect. We need to define our database schema and create our db tables for our module. First we need to create the .install file.

Creating the .install File
04:15

We need to add our hook_schema function to the .install file to define our first db table and schema for our module.

Using the hook_schema Function – Part 1
06:33

We need to add the schema for our hook_form_alter data. We add another schema array to our .install file.

Using the hook_schema Function – Part 2
05:20

Every time we add a schema function to our .install file we also need to uninstall and reinstall our module for the new schema to work. We also need to clear out all variables that we're setting when we uninstall our module. We do this by adding the hook_uninstall function.

Using the hook_uninstall Function
05:23

We can add more functions to our .install file to manage the install and updating process.

Using the hook_update Function
04:24
+
Node Hooks and Database System
5 Lectures 19:26

We need to allow our module to modify a node when the user uses the hook_form_alter, so we need to add node hooks to allow us to modify the nodes that we have enabled for use with our module.

Adding Node Hooks – Part 1
04:18

We continue to add node hooks to allow for updating and deleting any modifications that we've made to our nodes.

Adding Node Hooks – Part 2
03:21

We still need to add our values set using our hook_form_alter to our database table. To do this we'll write some database wrapper functions that will query the db.

Database Queries – Part 1
04:04

We add additional db queries to help with deleting data

Database Queries – Part 2
03:05

We need to learn how to make our database query code as secure as possible and we look at some Drupal best practices for doing this.

Database Abstraction Layer
04:38
+
Block System and Theming
5 Lectures 23:55

We add a hook_block_info function that makes Drupal aware of our custom Facebook Feeds block.

Preview 05:16

We need to show content in our custom block so we add a hook_block_view function that will define our block contents.

Preview 05:06

We need to use a database query in order to display our Facebook posts inside the custom block.

Preview 05:41

Now that we have a block showing content we need to theme it with the custom style.

Preview 04:14

We have our custom code and <div> printing in our custom theme template. Now we need to add some custom style.

Preview 03:38
+
Security, Performance, and Testing of our Module
5 Lectures 20:33

We need to write secure code throughout our module project life cycle so in this video we look at the various documentation that the Drupal API provides to help us write secure code.

Drupal Module Security and Sanitization
03:22

We install and configure the Coder module to run automatic reviews of our contrib, core, and custom module code.

Installing the Coder Module
05:12

We need a system for running automatic tests of our custom module. We enable and configure the Testing module for this.

Conducting a Simple Test – Part 1
02:56

We now need to write a custom .test file and add this to our module.

Conducting a Simple Test – Part 2
05:06

We now need to enable our .test file via the Testing module and run our automated test.

Conducting a Simple Test – Part 3
03:57
About the Instructor
Packt Publishing
3.9 Average rating
7,241 Reviews
51,766 Students
616 Courses
Tech Knowledge in Motion

Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.

With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.

From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.

Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.