tip

How to cache usernames

As you may know, system function node_load statically caches nodes while called. For example if you look at at node with nid = 1000, system call node_load(array('nid' => 1000)). There is a database query and results are cached in node_load. So, when you call node_load twice for one node, all data comes from cache created on the first node_load run.

Read more...

How to write custom actions and triggers in Drupal

This tutorial is based on very useful comment by bboldi. I'll copy his code and do some modifications to it to show the right way of firing configurable actions. Here is the code that will create three custom triggers "On every page", "On random page", "On specific page" and two custom actions - configurable and non-configurable. All of the descriptions i'll do in the code comments.

Read more...

How to do Drupal core hack the right way

Of course, hacking Drupal core is not the right thing to do, because Drupal flexibility right now is very good with its APIs. But sometimes you can't live without a hack - there is some core routines not working as you wish.

Most of the problems after core hack are connected with updating Drupal core to the new version. I see three ways of partially solving them:

Read more...

How to redirect user to the custom page programatically after login

As there is no normal answer for this problem on Drupal.org forums i will show the way it works for Drupal 6:
1. Create new module or edit some custom module you created (do not edit core modules, it is really unprofessional)
2. Use this code snippet below:

Read more...

Auto form submit with javascript in Drupal

I'm sure some people know how to do this, but when i approached this task, i was confused.

Read more...