Installing Drush 8

Previously I discussed how to install Drush 6.x for use with Drupal 7. Here we’ll install Drush 8 for Drupal 8, specifically using Ubuntu 16.04 Server. The recommended method is to install using PHP’s Composer. First we install Composer itself: Then, install unzip to speed things up: Installing and Testing Drush 8 Install Drush 8.x: […]

Loading

Read More

Drupal 7: Display Page Elements Conditionally

In Drupal you often need to show page elements conditionally, usually based on variables like the URL or user identity. Fortunately, the Drupal API offers several functions that can help: hook_html_head_alter() template_preprocess_page() template_preprocess_html() drupal_match_path() drupal_get_http_header() user_is_logged_in() or user_is_anonymous() Modify the Page Header To add a tag to the header on every page, use hook_html_head_alter() in […]

Loading

Read More

Drupal: Programmatically Create a Block

So you want to add a block to your module in Drupal 7. First, define its internal name and human-readable title (for the Blocks UI) with hook_block_info(): /** * Implements hook_block_info(). */ function YOUR-MODULE_block_info() { $blocks = array(); $blocks[’YOUR-BLOCK-NAME’] = array( ‘info’ => t(‘MY BLOCK TITLE’), ‘cache’ => DRUPAL_NO_CACHE ); return $blocks; } Then, give […]

Loading

Read More