You are here

function blockgroup_form_block_admin_display_form_alter in Block Group 7.2

Same name and namespace in other branches
  1. 7 blockgroup.module \blockgroup_form_block_admin_display_form_alter()

Implements hook_FORM_ID_alter().

Add delete-link to the main block administration form for blockgroups.

File

./blockgroup.module, line 420
Add block groups to block configuration page

Code

function blockgroup_form_block_admin_display_form_alter(&$form, &$form_state) {
  $blockgroups = blockgroup_list();
  foreach ($blockgroups as $delta => $title) {
    $key = blockgroup_get_region($delta);
    $region_anchor = drupal_clean_css_identifier('region-' . $key);
    $block_anchor = drupal_clean_css_identifier('block-' . $key);

    // Add go-to-block link
    $rtb_options = array(
      'fragment' => $block_anchor,
      'attributes' => array(
        'name' => $region_anchor,
      ),
    );
    $rtb_link = l(t('Go to block'), $_GET['q'], $rtb_options);
    $form['block_regions']['#value'][$key] .= ' ' . $rtb_link;

    // Add go-to-region link
    $btr_options = array(
      'fragment' => $region_anchor,
      'attributes' => array(
        'name' => $block_anchor,
      ),
    );
    $btr_link = l(t('Go to region'), $_GET['q'], $btr_options);
    $form['blocks'][$key]['info']['#markup'] .= ' ' . $btr_link;

    // Add delete link to block
    $form['blocks'][$key]['delete'] = array(
      '#type' => 'link',
      '#title' => t('delete'),
      '#href' => 'admin/structure/block/manage/blockgroup/' . $delta . '/delete',
    );
  }
}