Module Development

By shane
2015-04-09 07:59
4 comments

If you are building out a Drupal 7 site you may some day run into a situation where you need to have more dynamic options for a field attached to a content type (or any other type of entity). If the default allowed values text area will not work for your situation, then you have come to the right place. In this tutorial, we will discuss two different ways to create a more dynamic options list for extending your allowed values.

By shane
2015-03-28 21:09
1 comment
Daily Dose of Drupal Episode #199

In the last episode, we learned about the Drupal Subuser module. In this episode, we continue where we left off but take a look under the hood at the module code of the Drupal Subuser module.

By following along with this episode you will learn some things such as:

Daily Dose of Drupal Episode #171

The Drupal 7 Search Krumo Module extends the Devel module and makes it easier to debug PHP variables while developing Drupal modules or building Drupal themes. It adds a simple search box that allows you to quickly search through the Krumo output that is generated by the dpm function.

If you want to try it out quickly, simply download and install the module and run the following code on the variable you want to debug:

By shane
2014-08-06 20:48
2 comments
There are times when you want to programmatically embed a node display in a block or panel pane. You can do this by creating a block. You might try to use the node_view function to display the node. Doing so in a module might look something like this:
/**
 * Implements hook_block_info().
 */
By shane
2014-06-25 07:29
20 comments

I recently ran across a problem of needing multiple Drupal Commerce add to cart buttons on a single page. Instead of trying to add a second add to cart form, I decided it would be easiest to create a custom link that could then be used to add products to the cart. This is useful if you need to create multiple add to cart links on the same page, or if you just need to create custom add to cart links to place in other areas of your Drupal Commerce website.

There are some times in Drupal 6 where you push the limits of what the blocks interface can do. If you need to display the same block, multiple times on the same page, you will start to see these limitations. An example of where this is useful is a Newsletter signup form. Sometimes a client may want a newsletter signup form to be in the footer of every page, but also displayed more prominently on the contact form page.

By shane
2013-02-20 23:59
2 comments
Daily Dose of Drupal Episode #113

In the last two episodes, we covered building a basic Drupal 7 module that displayed a JavaScript confirmation before a user leaves a specific page. In this episode we continue where we left off and add the ability to display the JavaScript confirm form on specific content type node edit pages.

In this episode you will learn:

  • How to add a checkbox field on the administration form that displays all the content types on your Drupal site
  • How to verify you are on the node edit page of a specific content type
By shane
2013-02-19 22:54
0 comments
Daily Dose of Drupal Episode #112

In the last episode we covered creating a simple module to display a javascript confirmation popup before leaving a page. In this episode we take that a step further and add a nice administrative interface to the module.

In this episode you will learn:

  • How to implement hook_menu to add an administrative page to your custom Drupal module
  • How to build a Drupal administrative form
By shane
2013-02-18 18:23
3 comments
Daily Dose of Drupal Episode #111

Learning module development in Drupal is not easy, but this Daily Dose of Drupal episode provides a very simple but practical module development video tutorial to use when learning about Drupal Module development. If you have a complex form on your Drupal websites, whether it is a Node creation form or perhaps even a webform, you may want to warn users before they navigate away from the page. This can help inform users that if they navigate away from the page before submitting the form, they may lose the contents of the form.

By shane
2013-01-22 23:13
3 comments
Daily Dose of Drupal Episode #92

The Drupal 7 Form Builder module is a handy module for those new to building forms with the Drupal Form API. The module provides a nice, centralized interface for building out Drupal forms.

In this episode you will learn:

  • What is the Drupal 7 Form Builder module and why might it be useful
  • How can the Drupal 7 Form Builder module be used to export Drupal 7 Form API code.
Daily Dose of Drupal Episode #56

In the second part of this module investigator episode, I continue looking at the Drupal 7 Email field module and how the module implements Drupal 7 hooks to interact with the Drupal 7 Field API.

This is part 2 of the Daily Dose of Drupal episode 55. Unfortunately this one was even longer than part 1. I will try to shorten these videos up a little bit going forward.

In this episode you will learn:

    Daily Dose of Drupal Episode #55

    This is the first ever Module Investigator episode of the Daily Dose of Drupal. In a Module Investigator episode, I walk through the module PHP code of a module that I have covered in another Daily Dose of Drupal episode.

    In this episode I look at the code of the Drupal 7 Email Field module that I covered in the Daily Dose of Drupal episode 42.

    This is a rather long episode, but it covers a lot of important topics.

    In this episode you will learn:

      By shane
      2012-11-26 19:35
      0 comments
      Daily Dose of Drupal Episode #54

      Learn how to use the Drupal 7 Ajax Framework to create a simple Ajax driven link. This is a video version of a previous blog post called Drupal 7 Javascript Ajax Framework example from a link.

      In this episode you will learn:

      • How to create a simple Ajax driven HTML link on a Drupal 7 website using the Drupal 7 Ajax framework
      By shane
      2012-11-23 11:24
      13 comments

      Drupal 7 Ajax Framework Example

      For a Daily Dose of Drupal episode that covers this blog post topic as well, take a look at Drupal 7 Ajax Framework Link Example.

      By shane
      2012-11-14 23:35
      0 comments
      Daily Dose of Drupal Episode #50

      The Drupal Module Builder module makes it easy to build out a basic Drupal module with the boilerplate code already added. Using this module makes it easy to avoid typing all the hook implementations that normally are needed when building a Drupal module.

      In this episode you will learn:

      • How to use the Drupal Module Builder Module as a Drush plugin
      • How to run Module Builder drush commands to display .module file code
      • How to run Module Builder drush commands to display .info file code
      By shane
      2012-10-30 22:00
      1 comment
      Daily Dose of Drupal Episode #40

      Learn how to add theme functions and template files to you Drupal 7 module. This episode builds upon the my_example module created in the last episode and adds in a hook_theme implementation along with simple examples on how to create a theme function and template file in your module.

      In this episode you will learn:

      • How to add a hook_theme implementation to you your Drupal 7 module
      • How to add a theme function in your Drupal 7 module
      • How to create a theme template file (.tpl.php file) in your Drupal 7 module
      By shane
      2012-10-29 19:19
      2 comments
      Daily Dose of Drupal Episode #39

      Printing out straight HTML in your custom modules was so Drupal 6. Learn all about Renderable Arrays in Drupal 7 to make your Drupal 7 pages even more flexible.

      In this episode you will learn:

      • The basics of Drupal 7 Renderable Arrays
      • How to implement a simple Renderable Array Drupal 7 example
      By shane
      2012-10-04 23:22
      6 comments
      Daily Dose of Drupal Episode #22

      Continued from the last episode of the Daily Dose of Drupal, this episode continues Drupal 7 module development work with the Database API to pull data from the database and display it on a page.

      In this episode you will learn:

      • How to pull data from the Drupal database using the Drupal 7 db_query function
      • How to use db_select and the Database API's dynamic query building to pull data from the database
      • How to display data using a theme function to output data as a table
      Daily Dose of Drupal Episode #21

      This episode works off the the previous episode to create a custom Drupal 7 form using the Drupal Form API, and then looks at how to submit data from the Drupal form into a Drupal database table.

      In this episode you will learn:

      • How to use hook_menu, hook_permission, and drupal_get_form to create a custom Drupal form page
      • How to create a custom Drupal 7 form using the Drupal Form API
      • How to add a validation function to the Drupal 7 form
      • How to add a submit function the Drupal 7 form
      By shane
      2012-10-02 13:10
      4 comments
      Daily Dose of Drupal Episode #20

      In this example we create a new Drupal 7 module with the purpose of creating a database table inside our Drupal 7 module. We look at hook_schema and the Drupal Schema API to create a new database table.

      In this episode you will learn:

      • How to create a Drupal 7 module with an .install file
      • What hook_install, hook_uninstall, and other various installation hooks do inside your .install file
      • How to implement hook_schema in your Drupal 7 module
      • How to use the Schema API for create Drupal database tables
      Subscribe to Module Development