Drupal 7

Drupal Code Style Review Git Commit Hooks

A nice feature for protecting a repository from badly formatted code that violates Drupal coding standards is to install Coder at the global drush level (not in a specific website) and then use Drupal Code Quality (dcq) to run that code review as a git commit hook that runs as you attempt to commit your code.

Installation instructions are here.

Theme Templates for Fields

THis page is a great source for naming conventions for templates that come directly from core Drupal 7
https://drupal.org/node/1089656

Example:
If the field has the machine name "field_map_address" Then the basic template to override the field would be "field--field_map_address.tpl.php"

Flush all caches and it should appear.

White screen in Drupal Development

In Drupal development it can be annoying to have just a blank white screen of death WSOD present you with no helpful information.

Adding these lines to your settings.php file will help make the WSOD more helpful
REMOVE them from production server.

Collapsible content in Drupal 7

Drupal 7 Makes it pretty easy to Have toggle-able / collapsible content by treating it as a fieldset.

php output debug

This output debug is is a quick snippet to use when Devel's krumo output is not available.

Drupal Theme example

Just a quick example for Drupal template registration:

Declared in the .module

Drupal menu hook

Here is a nice set of info on various aspects of a hook_menu for Drupal 7
http://drupal.stackexchange.com/questions/62473/how-should-i-implement-h...

And of course for other questions you can always consult the menu hook API
https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...

Drupal t function with variables

I often see the t function which is designed for both security and translation used incorrectly in regard to variables. The t() function should not be passes a variable directly

Live server / Development server switch

Sometimes you need different values to be used on dev and live servers.

Here are two examples:

Installing drush

Here are some commands for installing drush from the command line

sudo apt-get install php-pear
pear channel-discover pear.drush.org
pear install drush/drush
drush version
pear upgrade drush/drush

But this is the new preferred way using Composer on *nix

# install composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=bin --filename=composer
# You may need to mkdir ~/bin first if you don't have one.

Pages

Subscribe to RSS - Drupal 7