Tag Archives: Drupal 7

Drupal 7 – Get path alias by Node ID or Term ID

We did talk about using drupal_lookup_path() to get path alias.

The above function is still working in Drupal 7. We could also use the url() to get the path alias url as well.

// Get the node id path alias
url('node/' . $tid);

// Get the term id path alias
url('taxonomy/term/' . $tid);


Done =)


Drupal 7 – Check add or edit in node form alter

If we want to alter a node form of a specific content type using hook_form_alter(), we may want to know whether the form is for node creation or edit. In this case, we can add a checking as follow:

function <module>_form_<content-type>_node_form_alter(&$form, &$form_state, $form_id) {
  $node = $form_state['node'];
  if (isset($node ->nid)) {
    // Node edit
  } else {
    // Node add


Done =)

Drupal 7 – Avoid HTML tags stripped by CKEditor

Since version 4.1, CKEditor introduced the Advanced Content Filter(ACF) which limits some HTML tags so as to match the editor configuration in the best possible way. But that’s really annoying to me.

In order to disable the ACF, goes to @admin/config/content/ckeditor.

Select the profile and goes to Advanced Options. Add the following Custom JavaScript configuration.

  • config.allowedContent=true;

Continue reading Drupal 7 – Avoid HTML tags stripped by CKEditor

Drupal 7 – Alter the module execution order

Sometimes you may have 2 different modules implementing hook_form_alter() on the same form. In that case, the order of the module execution would follow the alphabetic order of the module name. If you want to alter the execution order, you could either update the system table in database or install the Modules Weight module.

1. Download and install the Modules Weight.

2. Go to admin/config/system/modules-weight to adjust the module weight.

Done =)


Drupal 7 – The form has become outdated

After enabling the Cache blocks option @ admin/config/development/performance, the form inside a custom block throws the following error.

  • The form has become outdated. Copy any unsaved work in the form below and then reload this page.


One work around is to disable cache for that specific custom block and this could be done by adding the DRUPAL_NO_CACHE in your hook_block_info().
Continue reading Drupal 7 – The form has become outdated

General Assembly – Drupal Workshop in Hong Kong


General Assembly Hong Kong and I will be giving a Drupal Workshop on 14th August 2013 at the Hive. Make your reservation at the GA website.

Drupal is an open source Content Management System (CMS) and in this 2 hours workshop, we will go through the basic concepts on working with Drupal including Content Type, Node, Block, Module and Theme.

This class is a stepping stone for you to get into the Drupal world. Whether you are web developer, an entrepenuer or a project manager, by understanding the Drupal habitat, you will be able to consider whether Drupal is fit for your career, your business or your project.

Hope to see you there~ =)

Venue address:
The Hive
21st Floor, The Phoenix Building
No.23 Luard Road
Wan Chai
Hong Kong

Google Map

Ubercart – Charge throught membership subscription on Drupal 7

I have never tried to build a Drupal application with paid membership. Both Ubercart and Drupal Commerce provide membership subscription feature. This example is a proof of concept on implementing paid membership on Ubercart.

1. Enable the Roles module in Ubercart.
Continue reading Ubercart – Charge throught membership subscription on Drupal 7