Drupal: Block Inject Filter Module

Built a Small Drupal Module Last night. "Block Inject Filter".

Many times, mostly in content sites, the administrators find it difficult to find means of inserting ads in all of their articles, at the end of a per-defined paragraph, say 2nd paragraph. Block Inject Filter solves this by providing a configurable Text Filter that can be used on any Input Format in Drupal.

It can be configured to inject any predefined Custom Block into all content that use the Text Format which has the filter configured.

Drupal : Comment Limit By Role : Module to restrict the number of comments by any user per day, based on his user role

Developed this module to restrict the number of comments that a user can post in a day (last 24 hours) based on his role. The limits can be configured for each role from the configuration page. This is a modification of the contrib Module Comment Limit.

Developed this for NoiseFromAmerika.

Sandbox Project on Drupal.org is at http://drupal.org/sandbox/saitanay/1635606

Article Spinner API

Built an API for the Article Spinner. Was fun building it over the weekend. Infact it is the first webservice that I built for a Drupal system. This API allows users of ArticleSpinner.in to spin articles programatically without having to manually copy-paste into the form at www.articlespinner.in

Coming soon would be a Drupal Module that allows you to spin the content automatically when you make a post!

Drupal : Order of Hook Execution

Ever wondered what would be the order of execution of same hooks from different modules.

Say you have two modules active m1 and m2, each of which have the following functions
m1_node_presave($node) : Replaces Node's Title with "Title A" before saving
m2_node_presave($node) : Replaces Node's Title with "Title B" before saving

What would be the title of the node when saved?

Then you gotta check out hook_module_implements_alter

Drupal: node_save and special characters

  • Trying to create nodes or taxonomy terms programatically?
  • Have characters like "é", "è" or "à" in the title or body or any of the fields?
  • Struck with database errors while doing node_save ?
  • Is the text being truncated after the first occurrence of such a character?

Stop pulling out your hair on these encoding/charset problem...

With Drupal, everything is encoded (and expected) in the UTF-8 charset.

Drupal: Use EntityFieldQuery instead of node_load

I had a situation similar to this:

I had to fetch a bunch of nodes using a query like select * from nodes where

In each node, load the node, using node_load, check if a field has certain value

Based on that, perform some actions on the node and save the node.

The problem here was that the nodes that I was trying to loop through belong to a content type that has like 5 fields. And doing a node_load was resource heavy as it would have to perform a join operation on 50+ tables to get the values of all the fields of the node.