Last updated 3 January 2012. Created on 23 January 2008.
Edited by preetinder, NancyDru. Log in to edit this page.

Helpers is a library, or toolbox, with lots of very useful functions that help you build your modules and sites with joy and work faster and smarter. It is actually six modules in a single package; you may enable only the parts you need.

A helper would, for example be: number_to_currency(), or distance_of_time_in_words(). Or off course something like select_year(), or even select_country().

Basically all kinds of interesting and extremely useful functions that are too specific to make it into core, but still very handy to have at hand. Stuff that you have wondered that "would be very useful in addition to the default PHP".

How cool would it be to call a $form['country'] = select_country() and get a "select your country" select list, pre-filled with all the known countries in the world? Or to have a ready made function to render any number as a currency? Or even to render any percentage in a star-rating piece of HTML ("render_rate_as_stars()") etc.

This is part of our nefarious plan to "bring more Ruby on Rails delight to Drupal". And most of all to make Drupal a developer-friendly environment (where developing no longer requires you to think about the folks that might put the currency symbol behind the value... But where it is simply a case of calling a proper function.

The following pages provide information on which functions are available and provided by each module. Feel free to submit patches for more functions.

Installation

Normal module installation applies.

There are six modules in the Helpers package. You may enable each of them individually, except the Helpers_form module also requires the Helpers_theme module.

Settings

There are no settings for any of the modules.

HOW TO CONTRIBUTE

Some notes on contributing.

  • We don't allow just anyone to write into this module, because that would undermine the goal "creating a good and helpful toolbox". So please upload patches for this module (as a "feature request").
  • Once we have seen your contributions, and we like them, we will agree on you writing directly to the module. Obviously you'd need write access first!

CODING STANDARDS

All applications must follow the Drupal coding standards. But we want something more:

  • Name your functions very clearly. "Theme_box" is not as good as "theme_general_block_element." "Convert_currency" is far less descriptive than "convert_currency_to_decimal." Be creative, and look at the other functions for inspiration.
  • No need to include the word "helper" in your functions. Although Drupal has a guideline to name all the functions "module_name_foo_bar," we break this. Helpers must be useful, not finger-breaking-complex to type. Hence we prefer "theme_read_more" above "theme_helpers_read_more."
  • Remove functions that went into core. I believe that a lot of functions from the helpers might make it into core (indeed several have been specifically back-ported). Once they are in, please remove them from this module. Obviously, this is easier if the code is localized and not spread all over the place.
  • Link to issues. If a patch in the queue tries to insert a function from this module into core, provide a link to that issue-thread.
  • Doxygen. Each function MUST have documentation. A change to a function, REQUIRES you to change the docs too, and that also means the appropriate handbook page(s) as well.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.