db_select → Вывод тэгов с количеством нод в блок
t(‘Tags’),
);
return $blocks;
}
function tax_menu_block_view($delta = ‘’) {
$block = array(
‘subject’ => ‘’,
‘content’ => ‘’,
);
if ($delta == ’tax_menu’) {
$block[‘subject’] = ‘Tags’;
$block[‘content’] = get_items();
}
return $block;
}
function get_items() {
$query = db_select(’node’, ’n’);
$query->innerJoin(‘field_revision_field_tags’, ’t’, ’n.nid = t.entity_id’);
$query->innerJoin(’taxonomy_term_data’, ’td’, ’t.field_tags_tid = td.tid’);
$query->condition(’td.vid’, VOCABULARY. ‘=’);
$query->fields(’td’, array(’name’, ’tid’));
$query->groupBy(’td.tid’);
$query->addExpression(‘COUNT(*)’, ‘c’);
$query->orderBy(’td.name’, ‘ASC’);
$result = $query->execute();
foreach ($result as $item) {
$items[] = l($item->name . ‘(’ . $item->c . ‘)’, ’taxonomy/term/’ . $item->tid );
}
$attributes = array(
‘id’ => ’tax_menu_list’,
);
$output = theme(‘item_list’, array(‘items’ => $items, ’type’ => ‘ul’, ‘attrebutes’ => $attributes ));
return $output ;
}