When using PHP functions such as array_map, usort or preg_replace_callback, you are forced to pass in a single-parameter callback function, making it impossible to send additional context information to the callback. But it ain't necessarily so.
Function objects, aka Functors, are here to help.
For the information geek, we need a generic filter that sends the text fragment to any pre-defined system command, and sets the rendered HTML output as the output of the command. Graphviz Filter is a special case of such a filter, but we really need a generic system.
Some design issues arise: Each of these programs produces output in a variety of formats.
The Twitter dataset is an insanely valuable source of useful social networking information. That explains the huge number of Twitter-related sites that spring up, each one performing one specific analysis of Twitter data. The one I was looking at today is TwitterSheep which just creates a tagadelic-type cloud of keywords, from a user's followers' bios. Pretty neat idea, but it was frustrating that the Web application didn't let me actually see who of my followers are in which category - and make a list out of them, and email them, etc.
One of the recurring requests in the Views Bulk Operations issue queue is to create a downloadable archive of files attached to nodes. While the general case is not trivial to solve, I was recently hired by research on BLOGS to write a more specific action: create a Zip archive of all images stored in imagefields.
I rely on actions extensively to build functionality in my sites. I find them convenient for business logic because they are packaged chunks of functionality that can be called from many places, including Trigger, Rules, and VBO. Today, I've added a new place where actions can be called: the URL. Actions REST provides this functionality.
Consider a job site where a supplier receives an invitation to participate in a project. The supplier logs on the site and views the invitation, then wants to accept or decline it.
Given a list of videos tagged with a specific vocabulary, I wanted to show a view of these videos on the page of another node type (a "channel") that is also tagged with the same vocabulary. The idea is to create video channels that implicitly relate to videos by sharing taxonomy terms, instead of explicitly relating the videos to their channel (using node references for example). The videos should show on the channel's node page.
A case in point: I recently added to Sheetnode the feature of editing the spreadsheet fullscreen. While every Flash component has a fullscreen option, I couldn't even find a jQuery component that implements this functionality.
In an earlier article, I tried to argue, somewhat inconvincingly, that theming menu items is less than ideal. I think my example was not well chosen. Fortunately, real life furnished me with a perfect example, during the course of my work.
A client required to associate specific icons with menu items, by specifying a custom class for specific menu items. A legitimate request that has been around for years on desktop menu systems. How to implement this on Drupal? Not so simple using the current menu theming setup.
Drupal code is heavily array-based, and it utilizes array structures that can be many levels deep. Here are a couple of complementary functions to query and manipulate such arrays:
* Search for a key in an array, returning a path to the entry.
* @param $needle
* A key to look for.
* @param $haystack
* A keyed array.
* @param $forbidden
* A list of keys to ignore.
* @param $path
* The intermediate path.
It's no secret that version control on Drupal is hard. Specifically, the problem of iteratively building a site on a staging server, then moving it to a running production system has been the source of countless wasted hours, lost data, pulled hair, blog posts, and modules promising a solution. On Twitter, some would say #drupal #migration #fail.
This post is not the answer to this problem. I just want to show actual code that helps with a small part of it, namely keeping views under version control.