In light of both my own needs and other issues like

There is a need for more customisation of homebox by external modules. In this case, the links generation of "Add a block" are happening all in homebox_build and there is no way to alter/preprocess them (html get generated too soon).

So I created a new hook (hook_homebox_add_block_links) to provide a way to override the links generation of the "Add a block" section.

This allows total customization of the list of blocks. Instead of just overriding theming, this hook allows to add new information to the list of links or change its presentation completely.

For example, with issue #1822770: "Add a block" description for each available block, you can now do a very crude override like the following.

You could add:

       $list_item_content = homebox_add_link($info['info'], $page, $module, $delta, $options);
       if (isset($info['description'])) {
          $list_item_content .= '<p class="description">' . $info['description'] . '</p>';
       }
       $add_links[] = $list_item_content;

to the custom hook implementation like this:

 function YOUR_MODULE_NAME_homebox_add_block_links(&$allowed_blocks, $page) {
  $add_links = array();
  foreach ($allowed_blocks as $module => $blocks) {
    foreach ($blocks as $delta => $info) {
      $options = array();
      if (isset($info['used'])) {
        $options['attributes'] = array('class' => 'used');
      }
       $list_item_content = homebox_add_link($info['info'], $page, $module, $delta, $options);
       if (isset($info['description'])) {
          $list_item_content .= '<p class="description">' . $info['description'] . '</p>';
       }
       $add_links[] = $list_item_content;
    }
  }
  $add_links['restore'] = l(t('Restore to defaults'), 'homebox/' . $page->name . '/restore', array('attributes' => array('class' => 'restore')));
  return theme('item_list', array('items' => $add_links, 'title' => NULL, 'type' => 'ul', 'attributes' => array('class' => 'clearfix')));
}

And each Block link would have a description under it.

But the hook encapsulate enough code to be able to override a lot more and provide other interfaces. I hope this is useful to the community or that is in line with best practices.

Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ptsimard’s picture

Status: Active » Needs review
FileSize
3.44 KB

Here is the patch!

ptsimard’s picture

Status: Needs review » Closed (works as designed)

Having revisited this recently I'm closing this issue since the same outcome can be recreated using theme and preprocess functions.