Tuesday, May 11, 2010

Drupal makes life so much easier it's just beautiful.

It can actually be very easy and convenient to roll out an advanced application.

With Drupal you can create a content type, export it as a feature, extract the feature to the modules directory, open the exported .module file, add some relevant code and export the feature so your customer can easily install it.

The user story went something along the following lines. To get an insurance quote, collect information from a user. Submit the collected data to a webservice which will return a quoted premium which the user can then accept or decline. Some prompts went to the user interface and other details were emailed to various parties including an XML update to another administration system.

It was a matter of creating a new content type with CCK and exporting it as a feature using the features module. This conveniently creates all the files that make up a module. It creates a compressed tar which has to be extracted to the modules directory on your Drupal installation with tar xzf exportedfeaturefilename.tgz and then enabled in the modules administration.

In the myfeaturemodule.module file a menu call back was added for a admin form which was coded right there using the forms api. And voila, an admin page where an administrator could add configuration settings like the webservice endpoint and authentication details. It is worth mentioning that the persistence of these settings was taken care of with drupal's variable_get() function that stores it in it's variable table.

In the form alter hook the node's submit button text was changed to "Get quote". Some of the node's fields were hidden using field permissions module.

Using the node api
* the form input was first validated on the 'validate' event after which
* the 'presave' event executed code to authenticate a soap client using the soapclient module, and do a soap call populated with the form values to the webservice end point configured in the admin form.
* In the 'insert' event we had the node id to create links to two other menu call backs, one to accept and another to decline the quote. Which was added as a links in a message to the node's display.

There is more to it with exception handling and emails to be sent to another admin system, administrators and also confirmations to the person requesting the quote which Drupal made very convenient and easy. The email to the admin system was the only XML processing to be done. The soap client takes care of turning arrays into XML and vice versa.

Changing the permissions so anonymous is allowed to create content of the quote node type and adding a menu link to 'Get a quote' that links to the node creation form which cost the content type definition creation to get.

And voila! An advanced application with a great looking user interface, networking with security, persistence all taken care off.

Thank you dear Druapl community for making my life so much easier and creating a system that is so much fun to play with!

No comments:

Post a Comment

Thank you for your comment :)