Drupal 7

User login

Drupal 7: Views pager not showing!

A weird issues came up after upgrading from Views version 7.x-3.7 to 7.x-3.8. The pager was missing from all views.
After making sure that there are enough results to bring up a pager, and that the pager ID was unique for each view that shows up in the same page, we noticed the one thing that all views had in common: They all used Global: PHP fields.

Drupal 7: Addressfield - Change the order of the inner fields

A request that often comes up is to change the order of the Addressfield fields.
In this example, we are creating a custom module in order to position the Country field at the bottom.
It is a very simple function, and the other elements can be positioned in a similar fashion.

Drupal 7: Heartbeat comment messages show up twice!

Heartbeat messages were showing up nicely on a project we have been working on lately, bringing up all the member activities including changing the user account details, adding or editing nodes and commenting on nodes.
Everything was working fine right out of the box - except one minor inconvenience that we noticed: all comments were showing up twice in the heartbeat stream.

Configuring drupal cron jobs in crontab.

Drupal 7 has the ability to run cron automatically, but if there are tasks that really depend on cron, it only makes sense to ensure that cron is running in pre-defined time spans.

To make sure of that, we can configure the drupal cron to run from a server side command. So from the console, In crontab, the following line will trigger Drupal's cron

Drupal7: How to change an already existing text field to a text area

Here is a useful snippet that you can use to change an already existing drupal textfield into a text area. Just replace the field_machine_name with the machine name of the field that you would like to change.

Drupal Commerce - Translate Order total, Shipping Information, Billing information

If you do not want to use i18n_string and i18n_field in order to translate the Order total, Shipping & Billing Information texts, that show up in the cart and on the checkout pages when using Drupal Commerce, the following hacky approach should do the trick.

First, the following funcion can be used in your template.php file:

Drupal7 - How to rename the edit tab of a node

Here's a snippet that will rename the edit tab to a custom string, on node edit, depending on the content type.

It is easy to add different or additional validation criteria, depending on when you would like the Edit tab to show up with its brand new name.

This code should be placed in a custom module.

Drupal7 - Customize the search form

Here is the code to be used in the theme's template.php file that will override Drupal's search form.
If no template.php is available, just go ahead and create one.


Drush - Short Tips

Quick notes on Drush, while on a Drupal installation folder:

To create an archive of the current Drupal site:
drush archive-dump --destination=/backups/mysite.tar

To restore the files and databases for all sites in the archive.
drush archive-restore /backups/mysite.tar

To create a mysql dump of the current Drupal database:
drush sql-dump --result-file=
/mydb.sql

To drop all tables of the current Drupal database:
drush sql-drop

To import a new db file in the current Drupal database:

Drupal 7: How to check the available variables in a template (tpl) file

There is a very handy php function that allows us to quickly check all the available variables in a tpl file (e.g. html.tpl.php).
Assuming that the devel module is installed, the following line should do the trick:

<?php kpr(get_defined_vars()); ?>

Alternatively, a print_r should work just fine:

Pages

Subscribe to Drupal 7