Rules module provides a very powerful infrastructure to define conditionally executed actions based on occurring events. Let’s say a major upgrade to the core Triggers module. It makes a lot of sense to use Rules with Token module to create robust triggers, actions and even workflows without writing a single line of code.

For a recent project, I needed to access the vote value provided by the Voting API and use it with Rules. Strangely enough, when I checked the tokens available to Rules (which is very comprehensive), I realized that the vote value was not available.

Once I figured out that there is no very easy solution for that, I started to look for the easiest way to overcome that inconvenience and further ones. Custom Token module came to my help.

Use the following code to create a custom token (Type=Node) via the Custom Token module. This will make the vote of the logged-in user be available anywhere the regular tokens are available.

global $user;
$criteria = array('content_type' => 'node', 'content_id' => $node->nid, 'uid' => $user->uid);
$user_vote = votingapi_select_single_vote_value($criteria)/10;
return $user_vote;

Author: (16)


All web developers/designers need to use some tools (I am talking about non-application tools) to make their life easier. Most of these tools are quite famous and they generally depend on Firefox’s add-on system. (e.g. Firebug, Web Developer).

However, there is one other tool that I use quite often and very happy to have. So I decided that it deserves a mention in this blog. It is a javascript bookmarklet called Design by Allan Jardine.

Design features the following components:

  • Grid – overlays a highly configurable layout grid over a web-page. Grid can be set to match any set of dimensions, allowing easy development of CSS layouts in the web-browser.
  • Rule – displays rulers on a page, with all the expected features of the rulers found in a desktop design application, including guides which snap to block display elements and origin location control.
  • Unit – allows measurements to be made between any two points on a web-page, giving basic information about each of the points clicked on, and drawing a line on the page for the measurement.
  • Crosshair – draws a crosshair cursor on the page to assist in layout alignment. Cursor information is also presented in a tooltip.

Author: (16)


One of the best PHP tutorials I’ve ever read

Vikram Vaswani‘s language is clear and his humour is right on cue. Topics ranging from absolute beginner to slightly experienced. Highly recommended.


Author: (16)


There is an (in)famous error message in DWR which usually troubles newcomers. When you do a remote call, you get:

ERROR [DefaultConverterManager] No converter found for 'java.lang.Class'

It basically tells you that you have some member of type Class in the return type of your remote method, or in one of his child members’ fields.
It’s up to the author of that class to convert that field or not. But if you do not intend to convert Class field, and you’re sure that none of your parameter types or return values do contain a Class field, check for a enum in one of these. Having an enum raises (naturally) the same exception, and it’s easily overlooked. If so just add an enum converter and it’s done:

<convert converter="enum" match="your.full.package.EnumName"/>

PS: I assume this is also valid not just for return types but also parameters which tries to set a class name from javascript

Author: (8)


Need large-scale high-performance implementations of Drupal?

Pressflow might be your answer.

Via launchpad.net/pressflow:

Pressflow is designed for large-scale high-performance implementations of Drupal. It abandons support for out-dated versions of PHP and required MySQL version 5.x. It is also designed to take advantage of more advanced caching systems (e.g. memcached and APC) which are typically only available in dedicated hosting environments.

If you are using a typical “shared” hosting account (e.g. not dedicated or VPS), you will have a hard time taking advantage of much of what Pressflow has to offer. Similarly, if your traffic is modest, you may find it easier to stick with vanilla Drupal.

However, if you have a VPS or dedicated hosting, have 10s of thousands (to 10s of millions) of pageviews, are interested in using advanced caching systems like Varnish, and are concerned with growing traffic or traffic spikes, Pressflow is designed for you.

Author: (16)


Two tips about taxonomy in Drupal

When you hear the word “taxonomy” for the first time while trying to grasp what Drupal is about, it might look like a problem impossible to tackle. A major in science might help with the meaning of the word but nothing more. However, soon afterwards, you realize that it is not so difficult, you just need to use it properly and sometimes intelligently.

Sometimes when you get comfortable with the notion, it is easy to forget some easy tricks. Here is two of them that are related to parent/child relationship of taxonomy terms.

  • To show a term AND its children you can use Taxonomy: Term ID (with depth) option in the arguments section of the view that you are building.

To show the nodes belonging to a term you use:
taxonomy/term/x — where x is the term id to show, a number.

However, to show children nodes you need to add a depth variable. The syntax is:
taxonomy/term/x/y — where x is the term id to show, and y is the depth to go below x.

An example will explain this better. Let’s assume you have a structure such as this:

America (tid=1)
–Canada (tid=3)
–United States (tid=4)
—-Texas (tid=9)
——Amarillo (tid=11)
——Austin (tid=12)
—-California (tid=10)
——Los Angeles (tid=14)

If you use taxonomy/term/1, you’ll see only entries catalogued only under America (tid=1), but not its children.

If you use taxonomy/term/4/1, you’ll see entries for United States (tid=4) and its children to a depth of one; that is, you’ll see entries catalogued under Texas (tid=9) and California (tid=10).

If you use taxonomy/term/4/2, you’ll see entries for United States (tid=4) and its children to a depth of two; that is, you’ll see entries catalogued under Texas (tid=9) and California (tid=10) [this is the first level of depth], but also entries catalogued under Amarillo (tid=11), Austin(tid=12) and Los Angeles(tid=14).

Author: (16)


Content Profile is highly useful if you want to extend the default profile module with e.g. Content Construction Kit (CCK). While implementing I ran into a small problem. When I search for a username the results were directing me to the profile node but not the account page that I had created with Panels. Here are two simple solutions.

The first one uses the rules but might be a little less effective than the second as the rule is called whenever any users would request any node. This might make you loose 50ms per view. The second one might scare non-coders but is really easy to do actually.

1. via Rules:
import and use this rule and tweak it as you like.

2. via node-uprofile.tpl.php, source Michelle:

// We don't ever want to go to the nodeprofile itself.
// Always redirect to the user page.
if (arg(0) == "node") {
drupal_goto("user/$node->uid", NULL, NULL, 301);

Author: (16)


Search Lucene API

Even though the core search module is quite powerful, it is not that easy to find another module that would add Solr-like search functionality (faceted search, fielded sorting of search results, finer-grained content bias) to Drupal. The best search engine available, Apache Solr Search Integration, requires a separate search server or at least Java 5 or higher. These requirements are not always easy to satisfy by small or start-up websites.

Search Lucene API, intervenes right at this point. It has almost all the functionality of Apache Solr (not the same performance of course however quite satisfying) and it is much easier to implement. The following modules that depend on Search Lucene API make it even more powerful.

  • Search Lucene DidYouMean – Provides Google-like “did you mean” recommendations by detecting and correcting spelling errors based on the site’s content.
  • Search Lucene MoreLikeThis – Adds a block that displays content recommendations based on the text in the node being viewed.
  • Search Lucene CCK – Indexes CCK data as separate Lucene fields and adds options to expose them as bias fields.
  • Search Lucene Tagcloud – Adds a facet realm that displays facets as tagadelic-like links.

Author: (16)


Disabling all contributed modules at one go in Drupal

Sometimes -especially before version upgrades-, disabling all contributed modules can become quite frustrating. And inter-dependency of modules do not help at all.

The following method which allows you to update the system table in Drupal, works like a charm for me. You can use phpMyAdmin and/or shell access -> mysql.

UPDATE system SET STATUS = 0 WHERE filename LIKE "sites%"

Author: (16)


Multiple Internet Explorer versions side by side

I found this cool collection which install every single IE version (I mean it, there is even Internet Explorer 1.0), and you can use them simultaneously to test your web apps easily.


Author: (8)