You are here

function block_attributes_block_attribute_info in Block Attributes 7

Implements hook_block_attribute_info().

Key function for the declaration of all block attributes.

File

./block_attributes.module, line 120
Enhanced control over the HTML attributes of any Block.

Code

function block_attributes_block_attribute_info() {

  // Define the accesskey attribute, only for the block level scope.
  $info['accesskey'] = array(
    'label' => t('Access Key'),
    'description' => t('Specifies a <a href="@accesskey">keyboard shortcut</a> to access this block.', array(
      '@accesskey' => url('http://en.wikipedia.org/wiki/Access_keys'),
    )),
    'form' => array(
      '#maxlength' => 1,
      '#size' => 1,
    ),
    'scope' => array(
      BLOCK_ATTRIBUTES_BLOCK,
    ),
  );

  // Alignment property with the align attribute.
  $info['align'] = array(
    'label' => t('Align'),
    'description' => t('Specifies the alignment of the content inside a &lt;div&gt; element.'),
    'form' => array(
      '#type' => 'select',
      '#options' => array(
        '' => t('None specified'),
        'left' => t('Left'),
        'right' => t('Right'),
        'center' => t('Center'),
        'justify' => t('Justify'),
      ),
    ),
    'scope' => array(
      BLOCK_ATTRIBUTES_BLOCK,
      BLOCK_ATTRIBUTES_TITLE,
      BLOCK_ATTRIBUTES_CONTENT,
    ),
  );

  // Define the class attribute for all scopes but content which already has a
  // fixed class in block.tpl.php called 'content'.
  $info['class'] = array(
    'label' => t('CSS class(es)'),
    'description' => t('Customize the styling of this block by adding CSS classes. Separate multiple classes by spaces.'),
    'scope' => array(
      BLOCK_ATTRIBUTES_BLOCK,
      BLOCK_ATTRIBUTES_TITLE,
    ),
    'form' => array(
      '#maxlength' => 255,
    ),
  );

  // Define the HTML ID for all scopes.
  $info['id'] = array(
    'label' => t('ID'),
    'description' => t('Specifies a unique HTML ID for the block. It is recommended to avoid having the same HTML ID displaying several times on the same page, it should really be unique for each block.'),
    'scope' => array(
      BLOCK_ATTRIBUTES_BLOCK,
      BLOCK_ATTRIBUTES_TITLE,
      BLOCK_ATTRIBUTES_CONTENT,
    ),
  );

  // Define the style attribute for all scopes.
  $info['style'] = array(
    'label' => t('Style'),
    'description' => t('Enter additional styles to be applied to the block. For example: <em>font-size:20px;font-weight:bold;</em>'),
    'scope' => array(
      BLOCK_ATTRIBUTES_BLOCK,
      BLOCK_ATTRIBUTES_TITLE,
      BLOCK_ATTRIBUTES_CONTENT,
    ),
  );

  // Define the title attribute for all scopes.
  $info['title'] = array(
    'label' => t('Title'),
    'description' => t('The description displayed when hovering over the corresponding markup, the block, its markup or its content.'),
    'form' => array(
      '#type' => 'textarea',
      '#rows' => 2,
    ),
    'scope' => array(
      BLOCK_ATTRIBUTES_BLOCK,
      BLOCK_ATTRIBUTES_TITLE,
      BLOCK_ATTRIBUTES_CONTENT,
    ),
  );
  return $info;
}