i have problems when i'm trying to display the result of the following query:
SELECT COUNT(`entity_id` ) icount, `field_tags_tid`, `taxonomy_term_data`.`name`
FROM `field_data_field_tags`
INNER JOIN `taxonomy_term_data`
ON `taxonomy_term_data`.`tid`=`field_data_field_tags`.`field_tags_tid`
GROUP BY `field_tags_tid`
ORDER BY icount DESC
LIMIT 0 , 30
in a custom block in Drupal.
Here is my my_tags.module file:
<?php
function my_tags_block_info() {
$blocks = array();
$blocks['my_first_block'] = array(
'info' => t('My custom block'),
// DRUPAL_CACHE_PER_ROLE will be assumed.
);
return $blocks;
}
function my_tags_block_view($delta = '') {
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
};
$block = array();
switch ($delta) {
case 'my_first_block':
$result = db_query('SELECT COUNT(`entity_id` ) icount, `field_tags_tid`, `taxonomy_term_data`.`name`
FROM `field_data_field_tags`
INNER JOIN `taxonomy_term_data`
ON `taxonomy_term_data`.`tid`=`field_data_field_tags`.`field_tags_tid`
GROUP BY `field_tags_tid`
ORDER BY icount DESC
LIMIT 0 , 10');
$list = array(
'#theme' => 'links',
'#links' => array(),
);
foreach ($result as $record) {
$list['#links'][] = array('title' => $record->name , 'name' => $record->icount);
}
$block['subject'] = t('Popular tags');
$block['content'] = $list;
break;
}
return $block;
}
?>
And as a result it is shown only the 'name' field, but i need and the 'icount' field. Thank you.