The drop is always movingYou know that saying about standing on the shoulders of giants? Drupal is standing on a huge pile of midgetsAll content management systems suck, Drupal just happens to suck less.Popular open source software is more secure than unpopular open source software, because insecure software becomes unpopular fast. [That doesn't happen for proprietary software.]Drupal makes sandwiches happen.There is a module for that

Modulate: help with deploy and security

Submitted by nk on Wed, 2011-07-06 09:44

The last few days I wrote modulate. This Drupal 6 project has two important parts: a drush script copying various PHP snippets from the database into and modulate.module firing the copies and stopping eval from firing. The ultimate goal is that production could run with the php.ini setting disable_functions=eval. Right now, modulate works with custom block content, block visibility, node bodies, Views 3.x areas (header, footer, empty), default arguments and argument validators. Future plans include CCK textfields, custom panes, the Views customfield module and maybe even Rules (I could use help with that one) and of course a D7 port (help is welcome on that front as well -- it should be very easy). Oh and tests. Please write me tests :)

Creating a View with a username argument

Submitted by nk on Sun, 2011-07-03 00:18

I took a D7 site as a small side job the last few weeks mostly to learn Views and to get a chance to write a series of blogposts about how to create interesting things with D7 and Views. This is the first but not the last by far. So we needed a portfolio/username view. This is tricky -- you don't want a User: name, instead you need to add a User: uid contextual filter (argument in D6), specify a User validator and pick Only allow string usernames.

A geek's life, drive and usability

Submitted by nk on Sat, 2011-06-25 05:47

This might be boring (and might be better at chxramblings than here) but oh well. I will talk about some things that I perceive as I live the typical (?) geek, introvert life and the consequences for usability.

Be careful with stream wrappers

Submitted by nk on Sun, 2011-06-12 07:19

If you are writing a stream wrapper for Drupal 7 be mindful of two things:

  1. If your code throws a notice then up to and including 5.3.5 extremely weird bugs exist that completely break your script.
  2. When reading the whole file (for example: file_get_contents), as long as stream_read returns non-empty strings, the return value of stream_eof is ignored.


Don't hack core

Submitted by nk on Sun, 2011-06-12 05:53

Unless you are architecting core or interested in how that particular sausage is made, please leave in peace and don't hack core.

Aloha, Drupal!

Submitted by nk on Sun, 2011-05-29 02:52

People have been hollering for a WYSIWYG editor in core for a decade now or so. I have a vision for a limited but actually implementable version of this: the HTML5 Aloha editor in a field widget and in a text field formatter too for in place editing. In place editing is practically impossible in the generic case in Drupal as it's almost impossible to figure out what the raw version of the text is -- but for a text field, we actually have a grip. Anyone wanting to implement a node-based (we do not have entity_save) version of this for Drupal 7 can find me for mentoring the field API parts.

Closures in PHP 5.3 and PHP 5.4

Submitted by nk on Thu, 2011-05-19 03:18

The up and coming PHP 5.4 NEWS contains a cryptic entry "Added closure $this support back". This inspired me to write a blog post on closures because we might to want use them in Drupal 8*. Here is the simplest closure example

The mistake we made in templating

Submitted by nk on Sun, 2011-05-15 09:26

In a long and fierce debate with Jen Lampton (mikey_p, HedgeMage and heyrocker was involved some as well) we have arrived to an incredibly important realization: theming newbies apparently don't find simple logic (if, print, function calls) problematic they have problems with data structures!

About entity / field interaction -- remote entities

Submitted by nk on Fri, 2011-05-06 08:19

Most entities you meet in Drupal 7 are pretty complex objects stored in a local database. That's not something the field system expects. The field system, in fact, will never use more than entity_extract_ids to interface with your entities by design. Both that function and the field system will use metadata from hook_entity_info so that can't be skipped. This is how you can interact with the fields system if you just pull some entity data out of thin air (like a web service):

$skeleton_entity = entity_create_stub_entity($entity_type, array($entity_id, $revision_id, $bundle));
field_attach_load($entity_type, array($entity_id => $skeleton_entity));

The $revision_id and the $bundle are optional. Every other attach function has a similar signature. Happy skeleton coding!

The new Relation module

Submitted by nk on Mon, 2011-05-02 17:02

I plan to create a screencast as well but meanwhile, here is a useful guide to the new Relation 1.0 alpha 2. We have relation entities which describe the relation between two or more endpoint entities. Endpoints entities are described by an entity_id, entity_type pair which is stored in a special field called endpoints. This a relation_endpoint type field, you can't create more of this type in the UI nor you can delete the single field of this type from the UI.