User login

blocks

Give custom blocks template suggestions by type and views blocks by view ID

<?php
/**
 * Implements hook_theme_suggestions_HOOK_alter() for blocks.
 */
function kidneys_theme_suggestions_block_alter(array &$suggestions, array $variables) {

Block cache constants and other block-making tips

./modules/block/block.api.php:48: * - DRUPAL_CACHE_PER_ROLE (default): The block can change depending on the
./modules/block/block.api.php:50: * - DRUPAL_CACHE_PER_USER: The block can change depending on the user
./modules/block/block.api.php:53: * DRUPAL_CACHE_PER_ROLE is not sufficient.
./modules/block/block.api.php:54: * - DRUPAL_CACHE_PER_PAGE: The block can change depending on the page
./modules/block/block.api.php:56: * - DRUPAL_CACHE_GLOBAL: The block is the same for every user on every

Making a block example done live at WesternMassDrupalCamp 2011

The most fun lesson learned– passing in a pure integer to the $block['content'] in the implementation of hook_block_view causes an unsupported operand error so deep in the block rendering system the stack trace doesn't even know where it came from.

<?php
/**
 * Implements hook_block_info().
 */
function dgd7glue_block_info() {
  $blocks = array();
  $blocks['twoplustwo'] = array(
    'info' => t('Two plus two.'),
  );
  return $blocks;
}

Syndicate content