Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

What are modules and why use them?

From: Drupal 7 Custom Module Development

Video: What are modules and why use them?

Before I describe what modules are, let's explore the Drupal architecture at a high level for some perspective. Drupal is referred to as a Content Management Framework or CMF. A CMF is an application programming interface that can be used to create and customize a Content Management System. What does this mean practically? Drupal out of the box, consists of a number of components that can be used to build a website, but assembly is definitely required. This is different than a straight Content Management System such as WordPress.

What are modules and why use them?

Before I describe what modules are, let's explore the Drupal architecture at a high level for some perspective. Drupal is referred to as a Content Management Framework or CMF. A CMF is an application programming interface that can be used to create and customize a Content Management System. What does this mean practically? Drupal out of the box, consists of a number of components that can be used to build a website, but assembly is definitely required. This is different than a straight Content Management System such as WordPress.

WordPress is extremely good at building blogs and minimal websites and has been optimized to do just that. As a result, you can get a blog up and running in WordPress very quickly. There is a cost though, while WordPress and the other similar blogging content management systems do have the ability to be extended, they are purpose-oriented. Often the technical needs of extending functionality outweigh the capabilities of the core system. In contrast, Drupal can be used to create websites in many different scales. From simple sites such as brochures, blogs and portfolios, Drupal can also be used to scale to full enterprise grade applications with hundreds of thousands of users.

This flexibility is a double-edged sword. A core Drupal 7 installation is kind of like opening a box of building blocks and dumping them on the floor. There may be some recognizable shapes and some instructions on how to build a simple structure, but as a whole, it can be intimidating. Then focusing, one can see that each building block can connect to one another and experimentation and construction begins. With a context of what Drupal is in its core, the purpose and use of a module becomes clear. A Drupal module refers to software components that extend the functionality of a Drupal installation in order to accomplish a particular task or goal.

According to the official Drupal module developer's guide, there are three distinct kinds of modules. Core modules, which are included with the Drupal distribution itself. Each core module is approved by core developers and the community. Core modules are already included within your site installation. Examples include, field, help, and user. Contributed modules which are written and maintained by members of the Drupal community and shared with the GNU Public License or GPL, as Drupal is. The official repository of contributed modules is found at drupal.org/project/ modules where close to 11,000 distinct projects are hosted.

Examples of contributed modules include views, pathauto, and backup, and migrate. And finally, custom modules which are created by individual developers. The licensing of custom modules can vary. Some are shared only within a company or group, while others are released freely on public repositories such as GitHub. Sometimes they can be a fork or a variation of an existing contributed module. Like Drupal itself, Drupal modules are written in PHP. For Drupal 7, PHP 5.2.5 or higher is required while PHP 5.3 is officially recommended.

Contributed and custom modules can optionally have external dependencies, such as a software library that needs to be installed separately from the module itself. For example, the Print module requires a PDF writing library such as TCPDF to be available. When there is an external dependency, the library or libraries in question are typically not included with the module itself. This is done for multiple reasons. Potential licensing issues can be avoided which is particularly important for GPO licensed modules found on drupal.org.

Additionally, it avoids duplication of effort and cluttered source control repositories by separating disparate components logically. To review: Drupal modules extend the functionality of the core Drupal installation. There are core, contributed, and custom modules. Modules can interact with third-party libraries, but are typically not distributed with the libraries themselves. Using modules, a developer can manipulate virtually every aspect of a Drupal system without needing to alter the source code of core itself.

One of the published Drupal best practices is never hack core. This cannot be stressed enough. Changing core yourself makes it virtually impossible to apply updates and upgrades that offer bug and security fixes along with performance enhancements. Second, it makes it harder for the next person. Maintenance of the site by others becomes difficult at best as they have to reverse engineer the hacks created by their predecessors. And third, it can introduce security holes. Security vulnerabilities can be introduced inadvertently, as a sole developer does not have the same oversight and peer review that core contributions receive.

There are thousands of contributed modules that are available under the GPL license. So before writing a custom module, one should use due diligence and check to see if a module with that functionality already exists. If it does, then leverage the existing model and don't waste time reinventing the wheel. If the solution does exist, but there are deficiencies or shortcomings, submit an issue through the project homepage on drupal.org describing the problem and ideas on resolving it. The Drupal community actively request that developers regardless of their affiliation, contribute code back.

So if there is an issue that you know how to resolve, please do contribute your code as a patch back to the project maintainer through an issue. Proper attribution will be given and the end product will be improved based on the collaborative effort. I will demonstrate how to build a custom module to solve a particular problem. Storing and rendering information about Wind Farms, then importing data from a public source to populate the system. Some contributed modules will be leveraged to save time and avoid duplication of effort. In practice, use freely available modules to get as close as possible to the necessary solution, then custom build the functionality needed to get the job done.

Let's start building a custom module.

Show transcript

This video is part of

Image for Drupal 7 Custom Module Development
Drupal 7 Custom Module Development

24 video lessons · 5397 viewers

Jon Peck
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Drupal 7 Custom Module Development.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.