Helpers

The Helpers moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP.(s) is not my creation, but I am now a co-maintainer and have contributed functions to it.


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.

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 PHPRecursive acronym for "PHP: Hypertext Preprocessor" - is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.".

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 HTMLHyperText Markup Language - the coding standard for a web page. ("render_rate_as_stars()") etc.

This is part of our nefarious plan to "bring more Ruby on Rails delight to Drupal

Drupal

An open-source content management system that is used on this site and is taking over the world.". And most of all to make Drupal

Drupal

An open-source content management system that is used on this site and is taking over the world.
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.

Feel free to submit patches for more functions.

HOW TO CONTRIBUTE

Some notes on contributing.

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

CODING STANDARDS

All applications must follow the Drupal

Drupal

An open-source content management system that is used on this site and is taking over the world. coding standards. But we want something more:

  • Name your functions very clearly. "ThemeFor web sites, this refers to the "look and feel" of the site. It is also used to describe the code to produce that look._box" is not as good as "themeFor web sites, this refers to the "look and feel" of the site. It is also used to describe the code to produce that look._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

    Drupal

    An open-source content management system that is used on this site and is taking over the world.
    has a guideline to name all the functions "moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP._name_foo_bar," we break this. Helpers must be useful, not finger-breaking-complex to type. Hence we prefer "themeFor web sites, this refers to the "look and feel" of the site. It is also used to describe the code to produce that look._read_more" above "themeFor web sites, this refers to the "look and feel" of the site. It is also used to describe the code to produce that look._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 moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP.. Obviously, this is easier if the code is localized and not spread all over the place.
  • LinkThe technique which points to another page, anywhere on the Internet, from the current page. to issues. If a patch in the queue tries to insert a function from this moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. into core, provide a linkThe technique which points to another page, anywhere on the Internet, from the current page. 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.