Planet Drupal

Calling actions manually

Actions are a convenient way to package functionality in reusable chunks that can be called upon specific events. Countless modules expose actions, and at least the following consume them:

  • Trigger
  • Rules
  • Workflow
  • Views Bulk Operations

I found it useful to manually call actions in the business logic as well, typically during form submissions or in hook_nodeapi.

Overriding a theme function in a module

UPDATE: The comment by jtsnow resolves the general problem of overriding theme functions in a module using hook_theme_registry_alter(). Woohoo! But the specific problem described below to override the rendering of menu items remains.

I am trying to instruct the menu system to display each item's description underneath the item text, in a smaller font. I located the theme_menu_item() function in menu.inc that currently performs this task.

My distro wish list

"Install profile" is a really awful name, don'tcha think? I prefer "Drupal distro".

Here are some distros that I would love to work on:

The Automatic Resource Destructor pattern

Originally published at OpenCraft.

What happens if you need to open a file with fopen, but find that your function can exit at multiple points? It is tedious and error-prone to call fclose at each exit point. Alternatively, you could re-structure your code to only exit at the bottom, thereby calling fclose only once, but you would end up with many nested blocks that hamper readibility and are generally considered bad programming style.

A technique I like to use in those cases is the Automatic Resource Destructor.

The ultimate list-making device

The taxonomy system is one of the great contributions of Drupal to the technology of CMS: the ability to classify content with multiple vocabularies. Each vocabulary represents a dimension of concern in the content being managed. Further, a single taxonomy has a flexible structure: it can be linear, tree-like, even graph-like when multiple parents are chosen. Content can be restricted to be tagged with a single term, or multiple terms can be allowed. Finally, freetagging is supported.

Syndicate content