Block with popular terms?
Summit - January 9, 2009 - 22:22
| Project: | Term Blocks |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Hi,
Would it be possible to add a block option to show popular terms (als terms which may be not hold nodes)?
Thanks a lot in advance for considering adding it.
Preferrebly on D5 and D6 :)
Greetings,
Martijn

#1
Subscribing!
I'm looking for a module that would list 10 most popular tags in the last 24hours ... like we see on Twitter. Would be greatest way to keep pulse on what the community is bloging about in the last 24 hours or the last 48hours or 168hous.
I'm surprised there is no such solution in Drupal.
#2
I used the Tagadelic 6.x-1.2 module to acomplish this, could not find another solution, even tried views.
list($sort, $order) = explode(',', variable_get('tagadelic_sort_order', 'title,asc'));if ($delta!=NULL){
list($sort, $order) = explode(',', variable_get('tagadelic_sort_order_'.$delta, 'title,asc'));
}
else
{
list($sort, $order) = explode(',', variable_get('tagadelic_sort_order', 'title,asc'));
}
case 'count':usort($tags, "_tagadelic_sort_by_count");
break;
/*** callback for usort, sort by count
*/
function _tagadelic_sort_by_count($a, $b) {
return strnatcasecmp($a->count, $b->count);
}
/*** theme function that renders the HTML for the tags using item_list theme function
* @ingroup themable
*/
function theme_tagadelic_list($terms) {
$output = '';
foreach ($terms as $term) {
$items[]= l($term->name, taxonomy_term_path($term));
}
return theme('item_list',$items);
}
'tagadelic_list' => array('arguments' => array('terms' => NULL)),in the hook_block added code to get the extra block, wich I called popular:
First, add an extra code when $op=='view' to get the new delta, in this case 'popular_'.[term_id]
elseif (substr($delta,0,7)=='popular'){
$tmp = split("_",$delta);
$voc = taxonomy_vocabulary_load($tmp[1]);
$blocks['subject'] = variable_get('tagadelic_block_title_popular_'. $tmp[1], t('Popular Tags in @voc', array('@voc' => $voc->name)));
$tags = tagadelic_get_weighted_tags(array($voc->vid), variable_get('tagadelic_levels', 6), variable_get('tagadelic_block_tags_'. $tmp[1], 12));
$tags = tagadelic_sort_tags($tags,$delta);
//$blocks['content'] = theme('tagadelic_weighted', $tags);//return a chunk of 12 tags
$blocks['content'] = theme('tagadelic_list', $tags);//return a chunk of 12 tags
// $blocks['content'] = theme('tagadelic_weighted', $tags);//return a chunk of 12 tags
}
$blocks['popular_'.$voc->vid]['info'] = variable_get('tagadelic_block_title_'. $voc->vid, t('Popular Tags in @voc', array('@voc' => $voc->name)));$blocks['popular_'.$voc->vid]['cache'] = BLOCK_CACHE_PER_PAGE;
$options = array('weight,asc' => t('by weight, ascending'), 'weight,desc' => t('by weight, descending'), 'title,asc' => t('by title, ascending'), 'title,desc' => t('by title, descending'), 'random,none' => t('random'),'count,desc'=>'count,descending');$form['sort_order_'.$delta] = array(
'#type' => 'radios',
'#title' => t('Tagadelic sort order'),
'#options' => $options,
'#default_value' => variable_get('tagadelic_sort_order_'. $delta, 'title,asc'),
'#description' => t('Determines the sort order of the tags on the freetagging page.'),
);
variable_set('tagadelic_sort_order_'. $delta, $edit['sort_order_'.$delta]);Now I have an extra block with the popular terms besides the cloud tag for each vocabulary
It's still under development but you can have a look here http://tattooclick.com/
#3
Could you make an add-on patch for the tagadelic module for this?
Then it is available for everyone!
Thanks for considering this.
greetings,
Martijn
#4
Ok but what does tagadelic realy do?
I have just ran it and choose sort by weight...
It seems working like weight is a number of node the term refers to...
Maybe it's accidentaly (when I test this) but I an see no other exaplanation as weigts of taxonomy is everywhere 0.
So maybe sorting by weight (an option in tagdelic settings) is what we talk about here?