1 pumuki Feb 03, 2006 12:36
3 pumuki Feb 05, 2006 01:28
I got it!
Based in the information of the link below, I change _categories.php file to get a Category cloud (like technorati, del.icio.us) based in the number of posts of categories. To use it, the only thing you have to do is change the _categories.php of your skin for this. Here is the code:
<?php
/**
* This is the template that displays (recursive) list of (sub)categories
*
* This file is not meant to be called directly.
* It is meant to be called by an include in the _main.php template.
*
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
* @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
*
* @package evoskins
*/
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );
# You can customize the following as you wish:
if(!isset($cat_all)) $cat_all = /* TRANS: All categories, skin's categories list */ T_('All'); // Set to empty to hide
# global category list delimiters:
if(!isset($cat_main_start)) $cat_main_start = '<p>';
if(!isset($cat_main_end)) $cat_main_end = '</p>';
# Category delimiters:
if(!isset($cat_line_start)) $cat_line_start = '';
if(!isset($cat_line_end)) $cat_line_end = ' ';
if(!isset($cat_line_checkbox)) $cat_line_checkbox = false;
# Category group delimiters:
if(!isset($cat_group_start)) $cat_group_start = '';
if(!isset($cat_group_end)) $cat_group_end = '';
# When multiple blogs are listed on same page:
if(!isset($cat_blog_start)) $cat_blog_start = '<h4>';
if(!isset($cat_blog_end)) $cat_blog_end = '</h4>';
/*
* WARNING: the category list is displayed recursively.
* This is a little tricky. Don't modify below unless you really know what you're doing!
*/
// ----------------- START RECURSIVE CAT LIST ----------------
cat_query(); // make sure the caches are loaded
if( ! isset( $cat_array ) ) $cat_array = array();
/**
* callback to start sublist
*/
function cat_list_before_first( $parent_cat_ID, $level )
{ // callback to start sublist
global $cat_group_start;
if( $level > 0 ) echo "\n",$cat_group_start,"\n";
}
/**
* callback to display sublist element
*/
function cat_list_before_each( $cat_ID, $level )
{ // callback to display sublist element
$a = 5;
$b = 10;
$c = 15;
$d = 20;
$e = 25;
$f = 30;
$g = 40;
global $blogfilename, $cat_array, $cat_line_start, $cat_line_checkbox;
$cat = get_the_category_by_ID( $cat_ID );
echo $cat_line_start;
if( $cat_line_checkbox )
{
echo '<label><input type="checkbox" name="catsel[]" value="'.$cat_ID.'"';
if( in_array( $cat_ID, $cat_array ) )
{ // This category is in the current selection
echo ' checked="checked"';
}
echo ' />';
}
if ($cat['cat_postcount'] <= $a ) {
echo '<span style="font-size: 75%;"><a href="'.url_add_param( get_bloginfo('blogurl'), 'cat='.$cat_ID ).'">'.format_to_output($cat['cat_name'], 'htmlbody').'</a></span>';
} elseif ($cat['cat_postcount'] <= $b ) {
echo '<span style="font-size: 100%;"><a href="'.url_add_param( get_bloginfo('blogurl'), 'cat='.$cat_ID ).'">'.format_to_output($cat['cat_name'], 'htmlbody').'</a></span>';
} elseif ($cat['cat_postcount'] <= $c ) {
echo '<span style="font-size: 125%;"><a href="'.url_add_param( get_bloginfo('blogurl'), 'cat='.$cat_ID ).'">'.format_to_output($cat['cat_name'], 'htmlbody').'</a></span>';
} elseif ($cat['cat_postcount'] <= $d ) {
echo '<span style="font-size: 150%;"><a href="'.url_add_param( get_bloginfo('blogurl'), 'cat='.$cat_ID ).'">'.format_to_output($cat['cat_name'], 'htmlbody').'</a></span>';
} elseif ($cat['cat_postcount'] <= $e ) {
echo '<span style="font-size: 175%;"><a href="'.url_add_param( get_bloginfo('blogurl'), 'cat='.$cat_ID ).'">'.format_to_output($cat['cat_name'], 'htmlbody').'</a></span>';
} elseif ($cat['cat_postcount'] <= $f ) {
echo '<span style="font-size: 200%;"><a href="'.url_add_param( get_bloginfo('blogurl'), 'cat='.$cat_ID ).'">'.format_to_output($cat['cat_name'], 'htmlbody').'</a></span>';
} elseif ($cat['cat_postcount'] <= $g ) {
echo '<span style="font-size: 250%;"><a href="'.url_add_param( get_bloginfo('blogurl'), 'cat='.$cat_ID ).'">'.format_to_output($cat['cat_name'], 'htmlbody').'</a></span>';
} else {
echo '<span style="font-size: 300%;"><a href="'.url_add_param( get_bloginfo('blogurl'), 'cat='.$cat_ID ).'">'.format_to_output($cat['cat_name'], 'htmlbody').'</a></span>';
}
if( in_array( $cat_ID, $cat_array ) )
{ // This category is in the current selection
echo "*";
}
if( $cat_line_checkbox )
{
echo '</label>';
}
}
/**
* callback to display sublist element
*/
function cat_list_after_each( $cat_ID, $level )
{ // callback to display sublist element
global $cat_line_end;
echo $cat_line_end,"\n";
}
/**
* callback to end sublist
*/
function cat_list_after_last( $parent_cat_ID, $level )
{ // callback to end sublist
global $cat_group_end;
if( $level > 0 ) echo $cat_group_end,"\n";
}
// Start global list:
echo $cat_main_start;
if( $blog > 1 )
{ // We want to display cats for one blog
echo "\n",$cat_group_start,"\n";
if( !empty( $cat_all ) )
{ // We want to display a link to all cats:
echo $cat_line_start,"\n";
echo '<a href="',get_bloginfo('blogurl'),'">',$cat_all,'</a>';
echo $cat_line_end,"\n";
}
cat_children( $cache_categories, $blog, NULL, 'cat_list_before_first', 'cat_list_before_each', 'cat_list_after_each', 'cat_list_after_last', 0 );
echo "\n",$cat_group_end,"\n";
}
else
{ // We want to display cats for all blogs
for( $curr_blog_ID=blog_list_start('stub');
$curr_blog_ID!=false;
$curr_blog_ID=blog_list_next('stub') )
{ # by uncommenting the following lines you can hide some blogs
// if( $curr_blog_ID == 2 ) continue; // Hide blog 2...
if( ($curr_blog_ID == 1) && empty( $cat_all ) ) continue; // Hide blog 1 if requested
echo $cat_blog_start;
?><a href="<?php blog_list_iteminfo('blogurl', 'raw') ?>"><?php blog_list_iteminfo('name', 'htmlbody') ?></a>
<?php
echo $cat_blog_end;
// run recursively through the cats
cat_children( $cache_categories, $curr_blog_ID, NULL, 'cat_list_before_first', 'cat_list_before_each', 'cat_list_after_each', 'cat_list_after_last', 1 );
}
}
// End global list:
echo $cat_main_end;
// ----------------- END RECURSIVE CAT LIST ----------------
?>
You can change the number of posts necesary to the different weight of the fonts here:
$a = 5;
$b = 10;
$c = 15;
$d = 20;
$e = 25;
$f = 30;
$g = 40;
I thing i will be interesting to know blogs total post to change this values dinamically. Can someone help how get blog total post?
Thanks and sorry for my english!
4 laibcoms Jun 30, 2006 09:24
interesting.
Can you give a screenshot how it will look like after?
Thanks. :)
5 cslepage Sep 12, 2006 02:27
Will this work in 1.8.1? If not, is there a way to make it work?
6 cslepage Sep 16, 2006 21:42
:) I'm guessing the answer is no?
7 blueyed Sep 16, 2006 21:46
The answer is: try it.. :)
8 cslepage Sep 16, 2006 22:44
:) I have! But, the category plugin is sufficiently different from the old category structure that this hack does not apply. I would need to understand a great deal about plugins before I could adapt this hack to one.
9 bodo Nov 11, 2006 08:45
I created a Plugin for b2evolution 1.8 that displays a tag cloud:
http://blog.wannawork.de/index.php/2006/11/10/tag_cloud_plugin
10 cslepage Nov 11, 2006 15:49
I just installed it, and it works great-- thank you!
I want to display b2evolution caregory list like a tag cloud. For example http://www.eatdrinksleepmovabletype.com/tutorials/building_a_weighted_category_list/
I don't know how to do that, I only know that I have to change _categories.php (and I'm not sure)