Exercise on Drupal Module Development - Drupal Training Curriculum for Drupal Companies

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

Back to Drupal exercises for the in-class training

Exercise on Drupal Module Development

Areas covered

  • Build a module
  • Drupal API
  • Hooks
  • Forms
  • Best practices
  • Ajax
  • Javascript
  • Entities

Question 1 : Address Book v1 - Content types, Views, Features

Create a Drupal instance.
Create a content type addressbook_entry with fields name, email, phone and date of birth. (Use Date module and date field to store date of birth)
User can add addressbook entries to the site.
There should be a page that show all addressbook entries in a table with pagination in that page.
Above to that table, there should be a filter form that allows user to filter out address book entries. Filtering should be possible for each of four fields.

Modules to be used: views, features
Areas that need to be understood: content types, views, exposed filtering, features

Question 2 : Address Book v2 - Form API, Schema API, Custom report

Create a Drupal instance.

Create a custom table address_entry with fields as name, email, phone and date of birth.
Create pages like addressbook/add addressbook/%/edit and addressbook/search.
There should be custom forms for adding/editing and searching.
Create a block with Today's birthdays.

In the login form, change the label 'Username' to 'Login name' .

Use custom tables for this project. Use hook_schema to create custom tables in drupal. Add necessary permissions so that only authenticated users can add/edit content. Anonymous users can view and search data.

Objectives: Form API, views, hook_permissions, hook_menu, hook_block, Database API, Form Alter.

Question 3 : Address Book v3 - Form API, Entity, Views

Implement the address book using Drupal Entities and views. Entities should be created programmatically. This will look similar to Address book v1, only difference is that, instead of using content types/node entity, you have to implement a new entity addressbook. The entity need not be fieldable. The base table can include all fields.

Question 4 : Address Book v4 - Form API, Entity, Custom report, Ajax

Implement address book using Ajax API. - Add/Edit/Search/Delete
There will be /manage page where users can view the addressbook add form as well as the addresses already entered as a paginated list. From this page, users can add, edit and delete items. There should be a separate seach page. All the operations should be using Ajax.

Question 5 : Events module for a website - Form alter

Events admin should be able to create events.
Event should have the following properties:
Title
Description
Event Image (Optional)
Date and Time
Location - Predefined list - Taxonomy
Type of Event - Predefined list - Taxonomy

There should be a block on the site which list todays events. It should list the title of the event and time of the event. (not date). The title should be a link pointing to the page view of the event.

There should be a page where the user can filter and find the event he/she is looking for. The filter options should be Type of event and Date. The Type of event should list all available event types. The date should list the following.

Show all (default)
­ Current Month
­ Current Month + 1
­ Current Month + 2
­ Current Month + 3
­ Current Month + 4
­ Current Month + 5
Current Month + 6

Ie for Eg. Current month is February, 2014, it should list
Show all
February 2014
March 2014
April 2014
May 2014
June 2014
July 2014
August 2014

You have to use views to create this page. The exposed filters should be altered to achieve the desired functionality.

The events listing page and full node page should be themed properly, all information including image (if there are any), the date, type and location should be layout neatly. The listing page should only display a trimmed version of the description.

The output should be the custom module developed and any features imported.

We should be able to build this functionality in any websites by enabling the features and the custom module.

Assume that the time zone for the website will be GMT +5:30

Comments

Pertaining instructions for Question 2

lne_topos's picture

Thank you very much for this exercise, by far one of my favorites in terms of Drupal learning.

I have an inquiry about Question 2:
If one is creating a content type, not programmatically, but from the UI, how does one connect a custom table and custom add/edit forms with this content type?

I am not sure if the answer to my question would reveal the entire answer to the question and, to make sure that doesn't happen, a hint would suffice...

Thanks for pointing out this

vimaljoseph's picture

Thanks for pointing out this mistake. It should be create a custom table for address book - essentially rewrite the address book app you build using content type in exercise 1 with a custom module this time - to familiar with the Drupal API. Made the correction on the wiki.