You are here

function tagclouds_block_view in TagCloud 7

Implements hook_block_view().

File

./tagclouds.module, line 544

Code

function tagclouds_block_view($delta = '') {
  $blocks = array();
  if ($voc = taxonomy_vocabulary_load($delta)) {
    $blocks['subject'] = variable_get('tagclouds_block_title_' . $delta, t('Tags in @voc', array(
      '@voc' => $voc->name,
    )));
    $tags = tagclouds_get_tags(array(
      $delta,
    ), variable_get('tagclouds_levels', 6), variable_get('tagclouds_block_tags_' . $delta, 12));

    //$tags = tagclouds_sort_tags($tags, "hook_block_view");;
    $tags = tagclouds_sort_tags($tags);
    $blocks['content'] = theme('tagclouds_weighted', array(
      'terms' => $tags,
    ));

    //return a chunk of 12 tags
    if (variable_get('tagclouds_display_more_link_' . $delta, variable_get('tagclouds_display_more_link', TRUE)) && count($tags) >= variable_get('tagclouds_block_tags_' . $delta, 12) && variable_get('tagclouds_block_tags_' . $delta, 12) > 0) {
      $blocks['content'] .= theme('more_link', array(
        'title' => t('more tags'),
        'url' => "tagclouds/chunk/{$voc->vid}",
      ));
    }
  }
  return $blocks;
}