Category Archives: CMS

Drupal 7 – Core drag and drop not working

One day after i migrated a Drupal 7 website to a client’s server, the core drag and drop feature did not work. In addition, i could not edit the Context because nothing was shown when i select the condition. The Show row weights link was also missing.

Finally i found that i was not the only one who came across this problem. The following post is a similar scenario and probably the failure was caused by the PHP 5.3 on the client’s server.
Drupal Core – Drag and drop not working
 

Anyway, after i have enabled the Aggregate JavaScript files in Administration » Configuration » Development » Performance, the problem was gone.

Done =)

Drupal 7 – Apply sticky footer in Omega theme

We can make the section-footer sticky in Omega theme by adding the following piece of code in <your-theme>-alpha-default.css.

/* sticky footer */
html, body {height: 100%; margin: 0;}
#page {display: table; width: 100%;}
html>/**/body #page {height: 100%;}
*:first-child+html #page {height: auto;}
.section {display: table-row;}
html>/**/body .section-content {height: 100%;}
*:first-child+html body .section-content {height: auto;}

 

Kudos to Karl Kasischke.

Done =)

Reference: Has anyone tried to get a sticky footer to work with Omega?

Drupal 7 – Get taxonomy terms by EntityFieldQuery

The EntityFieldQuery is not limited to node, it can be used to retrieve any entity types in Drupal 7. Here comes an example about getting taxonomy terms with EntityFieldQuery.

I would like to retrieve all terms with of a specific vocabulary which has vid = 1 with the descending weight order.
Continue reading Drupal 7 – Get taxonomy terms by EntityFieldQuery

Drupal 7 – Get mulitple nodes using EntityFieldQuery and node_load_multiple()

We tried to get specific nodes using EntityFieldQuery.
Drupal 7 – Get specific nodes using EntityFieldQuery

It returns a list of node ids which fulfill the query conditions. The next step is usually the retrieval of the nodes by the node ids. This can be done by the following example using node_load_multiple().
Continue reading Drupal 7 – Get mulitple nodes using EntityFieldQuery and node_load_multiple()

Drupal 7 – Customize the user login block

In Drupal 7, there is a user login block. We can customize that block using the hook_form_FORM_ID_alter(). You can create a custom module or implement it directly in the theme template.php.

Here is a simple example written by Liam McDermott. You can add this in the template.php and replace THEMENAME by your theme name.
Continue reading Drupal 7 – Customize the user login block

Drupal 7 – form_set_error does not show

I have a custom form and i render the form using drupal_get_form() inside the .tpl.php. One day, i find that when the submission could not pass the validation, only the failed field was highlighted but without the error message. Then i find the following post suggesting that i should called the drupal_get_form() in the .module file or preprocess function instead of the .tpl.php.
form_set_error Not displaying error after invalid form submission

So i put the drupal_get_form() call in the preprocess function and set the form in the $vars so it could be printed in the .tpl.php. But that still could not solve the problem. Finally i come up with a simple solution which is just adding the following line in the .tpl.php.

<div><?php print theme_status_messages(array('display' => 'error')); ?></div>

 

Done =)

Reference: