Recent Topics

1 Dec 31, 2009 16:02    

I would like the tag cloud not to include certain tag(s).Any ideas ?

Reason: I have one particular tag that i add almost to every post, and it pops out as the biggest tag unnecessarily, and leaves the regular tags in shade.

2 Dec 31, 2009 19:18

See if this works for you.
Edit inc/widgets/widgets/_coll_tag_cloud.widget.php

Replace

$sql .= "
	 INNER JOIN T_items__item ON itag_itm_ID = post_ID
	 WHERE $where_cats
	   AND post_status = 'published' AND post_datestart < '".remove_seconds($localtimenow)."'
	 GROUP BY tag_name
	 ORDER BY tag_count DESC
	 LIMIT ".$this->disp_params['max_tags'];

With

$sql .= "
	 INNER JOIN T_items__item ON itag_itm_ID = post_ID
	 WHERE $where_cats
	   AND post_status = 'published' AND post_datestart < '".remove_seconds($localtimenow)."'";

if( $this->disp_params['filter_list'] )
{
	$filter_list = explode( ',', $this->disp_params['filter_list'] ) ;
	
	$filter_tags = array();
	foreach( $filter_list as $l_tag )
	{
		$filter_tags[] = '"'.$DB->escape(trim($l_tag)).'"';
	}
	
	$sql .= ' AND tag_name NOT IN ('.implode(', ', $filter_tags).')';
}

$sql .= "
	 GROUP BY tag_name
	 ORDER BY tag_count DESC
	 LIMIT ".$this->disp_params['max_tags'];

And this

'tag_ordering' => array(
		'type' => 'select',
		'label' => T_('Ordering'),
		'options' => array( 'ASC'  => T_('Ascending'), 'RAND' => T_('Random') ),
		'defaultvalue' => 'ASC',
		'note' => T_( 'How to sort the tag cloud.' ),
	),

With this

'tag_ordering' => array(
		'type' => 'select',
		'label' => T_('Ordering'),
		'options' => array( 'ASC'  => T_('Ascending'), 'RAND' => T_('Random') ),
		'defaultvalue' => 'ASC',
		'note' => T_( 'How to sort the tag cloud.' ),
	),
'filter_list' => array(
		'type' => 'textarea',
		'label' => T_('Filter tags'),
		'note' => T_('This is a comma seperated list of tags to filter'),
		'size' => 40,
		'rows' => 2,
	),

3 Feb 11, 2010 02:48

sorry for the *very* late response.I have looked into what i should do, but most of the above does not even exist in 2.4.7 nor 3.3.3 tag cloud widget. could you take another look ? i dont seem to find any "remove_sec" , "ordering" and most of the other mentioned above to be replaced

_coll_tag_cloud.widget.php for 2.4.7

<?php
/**
 * This file implements the xyz Widget class.
 *
 * This file is part of the evoCore framework - {@link http://evocore.net/}
 * See also {@link http://sourceforge.net/projects/evocms/}.
 *
 * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
 *
 * {@internal License choice
 * - If you have received this file as part of a package, please find the license.txt file in
 *   the same folder or the closest folder above for complete license terms.
 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
 *   then you must choose one of the following licenses before using the file:
 *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
 *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
 * }}
 *
 * @package evocore
 *
 * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
 * @author fplanque: Francois PLANQUE.
 *
 * @version $Id: _coll_tag_cloud.widget.php,v 1.19 2009/04/23 19:51:40 blueyed Exp $
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

load_class( 'widgets/model/_widget.class.php' );

/**
 * ComponentWidget Class
 *
 * A ComponentWidget is a displayable entity that can be placed into a Container on a web page.
 *
 * @package evocore
 */
class coll_tag_cloud_Widget extends ComponentWidget
{
	/**
	 * Constructor
	 */
	function coll_tag_cloud_Widget( $db_row = NULL )
	{
		// Call parent constructor:
		parent::ComponentWidget( $db_row, 'core', 'coll_tag_cloud' );
	}


	/**
	 * Load params
	 */
	function load_from_Request()
	{
		parent::load_from_Request();

		// SPECIAL treatments:
		if( empty($this->param_array['tag_separator']) )
		{	// Default name, don't store:
			$this->set( 'tag_separator', ' ' );
		}
	}


	/**
	 * Get name of widget
	 */
	function get_name()
	{
		return T_('Tag cloud');
	}


	/**
	 * Get a very short desc. Used in the widget list.
	 */
	function get_short_desc()
	{
		return format_to_output($this->disp_params['title']);
	}


	/**
	 * Get short description
	 */
	function get_desc()
	{
		return T_('Cloud of all tags; click filters blog on selected tag.');
	}


	/**
	 * Get definitions for editable params
	 *
	 * @see Plugin::GetDefaultSettings()
	 * @param local params like 'for_editing' => true
	 */
	function get_param_definitions( $params )
	{
		$r = array_merge( array(
			'title' => array(
					'type' => 'text',
					'label' => T_('Block title'),
					'defaultvalue' => T_('Tag cloud'),
					'maxlength' => 100,
				),
			'max_tags' => array(
					'type' => 'integer',
					'label' => T_('Max # of tags'),
					'size' => 4,
					'defaultvalue' => 50,
				),
			'tag_separator' => array(
					'type' => 'text',
					'label' => T_('Tag separator'),
					'defaultvalue' => ' ',
					'maxlength' => 100,
				),
			'tag_min_size' => array(
					'type' => 'integer',
					'label' => T_('Min size'),
					'size' => 3,
					'defaultvalue' => 8,
				),
			'tag_max_size' => array(
					'type' => 'integer',
					'label' => T_('Max size'),
					'size' => 3,
					'defaultvalue' => 22,
				),
			), parent::get_param_definitions( $params )	);

		// add limit default 100

		return $r;
	}


	/**
	 * Display the widget!
	 *
	 * @param array MUST contain at least the basic display params
	 */
	function display( $params )
	{
		$this->init_display( $params );

		global $Blog;

		if( empty($Blog) )
		{	// Nothing to display
			return;
		}

		global $DB;

// fp> verrry dirty and params; TODO: clean up
		// get list of relevant blogs
		$sql = 'SELECT LOWER(tag_name) AS tag_name, COUNT(DISTINCT itag_itm_ID) AS tag_count
						  FROM T_items__tag INNER JOIN T_items__itemtag ON itag_tag_ID = tag_ID
					  				INNER JOIN T_postcats ON itag_itm_ID = postcat_post_ID
					  				INNER JOIN T_categories ON postcat_cat_ID = cat_ID
					  				INNER JOIN T_items__item ON itag_itm_ID = post_ID
						 WHERE '.$Blog->get_sql_where_aggregate_coll_IDs('cat_blog_ID').'
						  AND post_status = "published" AND post_datestart < NOW()
						 GROUP BY tag_name
						 ORDER BY tag_count DESC
						 LIMIT '.$this->disp_params['max_tags'];

		$results = $DB->get_results( $sql, OBJECT, 'Get tags' );

		// pre_dump( $results );

		if( empty($results) )
		{	// No tags!
			return;
		}

		$max_count = $results[0]->tag_count;
		$min_count = $results[count($results)-1]->tag_count;
		$count_span = max( 1, $max_count - $min_count );
		$max_size = $this->disp_params['tag_max_size'];
		$min_size = $this->disp_params['tag_min_size'];
		$size_span = $max_size - $min_size;

		usort($results, array($this, 'tag_cloud_cmp'));

		echo $this->disp_params['block_start'];

		$this->disp_title();

		echo $this->disp_params['tag_cloud_start'];
		$count = 0;
		foreach( $results as $row )
		{
			if( $count > 0 )
			{
				echo $this->disp_params['tag_separator'];
			}
			// If there's a space in the tag name, quote it:
			$tag_name_disp = strpos($row->tag_name, ' ')
				? '&laquo;'.format_to_output($row->tag_name, 'htmlbody').'&raquo;'
				: format_to_output($row->tag_name, 'htmlbody');
			$size = floor( $row->tag_count * $size_span / $count_span + $min_size );

			echo $Blog->get_tag_link( $row->tag_name, $tag_name_disp, array(
				'style' => 'font-size: '.$size.'pt;',
				'title' => sprintf( T_('%d posts'), $row->tag_count ) ) );
			$count++;
		}
		echo $this->disp_params['tag_cloud_end'];

		echo $this->disp_params['block_end'];

		return true;
	}


	function tag_cloud_cmp($a, $b)
	{
		return strcasecmp($a->tag_name, $b->tag_name);
	}
}


/*
 * $Log: _coll_tag_cloud.widget.php,v $
 */
?>

_coll_tag_cloud.widget.php for 3.3.3

<?php
/**
 * This file implements the xyz Widget class.
 *
 * This file is part of the evoCore framework - {@link http://evocore.net/}
 * See also {@link http://sourceforge.net/projects/evocms/}.
 *
 * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
 *
 * {@internal License choice
 * - If you have received this file as part of a package, please find the license.txt file in
 *   the same folder or the closest folder above for complete license terms.
 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
 *   then you must choose one of the following licenses before using the file:
 *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
 *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
 * }}
 *
 * @package evocore
 *
 * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
 * @author fplanque: Francois PLANQUE.
 *
 * @version $Id: _coll_tag_cloud.widget.php,v 1.19 2009/04/23 19:51:40 blueyed Exp $
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

load_class( 'widgets/model/_widget.class.php' );

/**
 * ComponentWidget Class
 *
 * A ComponentWidget is a displayable entity that can be placed into a Container on a web page.
 *
 * @package evocore
 */
class coll_tag_cloud_Widget extends ComponentWidget
{
	/**
	 * Constructor
	 */
	function coll_tag_cloud_Widget( $db_row = NULL )
	{
		// Call parent constructor:
		parent::ComponentWidget( $db_row, 'core', 'coll_tag_cloud' );
	}


	/**
	 * Load params
	 */
	function load_from_Request()
	{
		parent::load_from_Request();

		// SPECIAL treatments:
		if( empty($this->param_array['tag_separator']) )
		{	// Default name, don't store:
			$this->set( 'tag_separator', ' ' );
		}
	}


	/**
	 * Get name of widget
	 */
	function get_name()
	{
		return T_('Tag cloud');
	}


	/**
	 * Get a very short desc. Used in the widget list.
	 */
	function get_short_desc()
	{
		return format_to_output($this->disp_params['title']);
	}


	/**
	 * Get short description
	 */
	function get_desc()
	{
		return T_('Cloud of all tags; click filters blog on selected tag.');
	}


	/**
	 * Get definitions for editable params
	 *
	 * @see Plugin::GetDefaultSettings()
	 * @param local params like 'for_editing' => true
	 */
	function get_param_definitions( $params )
	{
		$r = array_merge( array(
			'title' => array(
					'type' => 'text',
					'label' => T_('Block title'),
					'defaultvalue' => T_('Tag cloud'),
					'maxlength' => 100,
				),
			'max_tags' => array(
					'type' => 'integer',
					'label' => T_('Max # of tags'),
					'size' => 4,
					'defaultvalue' => 50,
				),
			'tag_separator' => array(
					'type' => 'text',
					'label' => T_('Tag separator'),
					'defaultvalue' => ' ',
					'maxlength' => 100,
				),
			'tag_min_size' => array(
					'type' => 'integer',
					'label' => T_('Min size'),
					'size' => 3,
					'defaultvalue' => 8,
				),
			'tag_max_size' => array(
					'type' => 'integer',
					'label' => T_('Max size'),
					'size' => 3,
					'defaultvalue' => 22,
				),
			), parent::get_param_definitions( $params )	);

		// add limit default 100

		return $r;
	}


	/**
	 * Display the widget!
	 *
	 * @param array MUST contain at least the basic display params
	 */
	function display( $params )
	{
		$this->init_display( $params );

		global $Blog;

		if( empty($Blog) )
		{	// Nothing to display
			return;
		}

		global $DB;

// fp> verrry dirty and params; TODO: clean up
		// get list of relevant blogs
		$sql = 'SELECT LOWER(tag_name) AS tag_name, COUNT(DISTINCT itag_itm_ID) AS tag_count
						  FROM T_items__tag INNER JOIN T_items__itemtag ON itag_tag_ID = tag_ID
					  				INNER JOIN T_postcats ON itag_itm_ID = postcat_post_ID
					  				INNER JOIN T_categories ON postcat_cat_ID = cat_ID
					  				INNER JOIN T_items__item ON itag_itm_ID = post_ID
						 WHERE '.$Blog->get_sql_where_aggregate_coll_IDs('cat_blog_ID').'
						  AND post_status = "published" AND post_datestart < NOW()
						 GROUP BY tag_name
						 ORDER BY tag_count DESC
						 LIMIT '.$this->disp_params['max_tags'];

		$results = $DB->get_results( $sql, OBJECT, 'Get tags' );

		// pre_dump( $results );

		if( empty($results) )
		{	// No tags!
			return;
		}

		$max_count = $results[0]->tag_count;
		$min_count = $results[count($results)-1]->tag_count;
		$count_span = max( 1, $max_count - $min_count );
		$max_size = $this->disp_params['tag_max_size'];
		$min_size = $this->disp_params['tag_min_size'];
		$size_span = $max_size - $min_size;

		usort($results, array($this, 'tag_cloud_cmp'));

		echo $this->disp_params['block_start'];

		$this->disp_title();

		echo $this->disp_params['tag_cloud_start'];
		$count = 0;
		foreach( $results as $row )
		{
			if( $count > 0 )
			{
				echo $this->disp_params['tag_separator'];
			}
			// If there's a space in the tag name, quote it:
			$tag_name_disp = strpos($row->tag_name, ' ')
				? '&laquo;'.format_to_output($row->tag_name, 'htmlbody').'&raquo;'
				: format_to_output($row->tag_name, 'htmlbody');
			$size = floor( $row->tag_count * $size_span / $count_span + $min_size );

			echo $Blog->get_tag_link( $row->tag_name, $tag_name_disp, array(
				'style' => 'font-size: '.$size.'pt;',
				'title' => sprintf( T_('%d posts'), $row->tag_count ) ) );
			$count++;
		}
		echo $this->disp_params['tag_cloud_end'];

		echo $this->disp_params['block_end'];

		return true;
	}


	function tag_cloud_cmp($a, $b)
	{
		return strcasecmp($a->tag_name, $b->tag_name);
	}
}


/*
 * $Log: _coll_tag_cloud.widget.php,v $
 */
?>

4 Feb 11, 2010 03:09

Just get the latest revision from CVS, I added the feature there.

5 Feb 11, 2010 03:25

sam2kb wrote:

Just get the latest revision from CVS, I added the feature there.

thanks but i did not even upgrade to 3.3.3 yet... do i have to use the cvs version to have this ? or can i just grab the file from css and put it into a 3.3 or 2.4.7 install (which i can not i presume |: )?

6 Feb 11, 2010 03:31

I think you can grab a single file. At least you can get the ideas.

7 Mar 01, 2010 20:10

okay, so i ve just made a cvs checkout 5 mins ago, and replaced the cvs _coll.tag.cloud...php with the 3.3 one, but it threw an error immedieately.

Then i decided to try the second option, modifying the 3.3 file accordingly like you said, everything seemed fine untill i actually tried to filter a word, i got a

Notice: Undefined variable: where_cats in /home/tilqi/public_html/inc/widgets/widgets/_coll_tag_cloud.widget.php on line 168

Fatal error: Call to undefined function remove_seconds() in /home/tilqi/public_html/inc/widgets/widgets/_coll_tag_cloud.widget.php on line 168

163.// fp> verrry dirty and params; TODO: clean up
               // get list of relevant blogs
	$sql .= "
     INNER JOIN T_items__item ON itag_itm_ID = post_ID
     WHERE $where_cats
    168.   AND post_status = 'published' AND post_datestart < '".remove_seconds($localtimenow)."'";

8 Mar 01, 2010 21:15

Try to copy this part of SQL query from 3.3

9 Mar 01, 2010 22:48

*phew* figured.turns out, the roots of "localtimenow" and those other new time stuff goes deeeeeper than i thought.. i ve tried defining variables here and there but they just didnt end, and i ended up removing them.

posting here in case anyone needs.

_coll_tag_cloud.widget.php with exclude tag functionality for 3.3.3:

<?php
/**
 * This file implements the xyz Widget class.
 *
 * This file is part of the evoCore framework - {@link http://evocore.net/}
 * See also {@link http://sourceforge.net/projects/evocms/}.
 *
 * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
 *
 * {@internal License choice
 * - If you have received this file as part of a package, please find the license.txt file in
 *   the same folder or the closest folder above for complete license terms.
 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
 *   then you must choose one of the following licenses before using the file:
 *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
 *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
 * }}
 *
 * @package evocore
 *
 * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
 * @author fplanque: Francois PLANQUE.
 *
 * @version $Id: _coll_tag_cloud.widget.php,v 1.19 2009/04/23 19:51:40 blueyed Exp $
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

load_class( 'widgets/model/_widget.class.php' );

/**
 * ComponentWidget Class
 *
 * A ComponentWidget is a displayable entity that can be placed into a Container on a web page.
 *
 * @package evocore
 */
class coll_tag_cloud_Widget extends ComponentWidget
{
	/**
	 * Constructor
	 */
	function coll_tag_cloud_Widget( $db_row = NULL )
	{
		// Call parent constructor:
		parent::ComponentWidget( $db_row, 'core', 'coll_tag_cloud' );
	}


	/**
	 * Load params
	 */
	function load_from_Request()
	{
		parent::load_from_Request();

		// SPECIAL treatments:
		if( empty($this->param_array['tag_separator']) )
		{	// Default name, don't store:
			$this->set( 'tag_separator', ' ' );
		}
	}


	/**
	 * Get name of widget
	 */
	function get_name()
	{
		return T_('Tag cloud');
	}


	/**
	 * Get a very short desc. Used in the widget list.
	 */
	function get_short_desc()
	{
		return format_to_output($this->disp_params['title']);
	}


	/**
	 * Get short description
	 */
	function get_desc()
	{
		return T_('Cloud of all tags; click filters blog on selected tag.');
	}


	/**
	 * Get definitions for editable params
	 *
	 * @see Plugin::GetDefaultSettings()
	 * @param local params like 'for_editing' => true
	 */
	function get_param_definitions( $params )
	{
		$r = array_merge( array(
			'title' => array(
					'type' => 'text',
					'label' => T_('Block title'),
					'defaultvalue' => T_('Tag cloud'),
					'maxlength' => 100,
				),
			'max_tags' => array(
					'type' => 'integer',
					'label' => T_('Max # of tags'),
					'size' => 4,
					'defaultvalue' => 50,
				),
			'tag_separator' => array(
					'type' => 'text',
					'label' => T_('Tag separator'),
					'defaultvalue' => ' ',
					'maxlength' => 100,
				),
			'tag_min_size' => array(
					'type' => 'integer',
					'label' => T_('Min size'),
					'size' => 3,
					'defaultvalue' => 8,
				),
			'tag_max_size' => array(
					'type' => 'integer',
					'label' => T_('Max size'),
					'size' => 3,
					'defaultvalue' => 22,
				),
			'filter_list' => array(
        'type' => 'textarea',
        'label' => T_('Filter tags'),
        'note' => T_('This is a comma seperated list of tags to filter'),
        'size' => 40,
        'rows' => 2,
    ), 
			), parent::get_param_definitions( $params )	);

		// add limit default 100

		return $r;
	}


	/**
	 * Display the widget!
	 *
	 * @param array MUST contain at least the basic display params
	 */
	function display( $params )
	{
		$this->init_display( $params );

		global $Blog;

		if( empty($Blog) )
		{	// Nothing to display
			return;
		}

		global $DB;

// fp> verrry dirty and params; TODO: clean up
// dh> oddly, this appears to not get cached by the query cache. Have experimented a bit, but not found the reason.
//     It worked locally somehow, but not live.
//     This takes up to ~50% (but more likely 15%) off the total SQL time. With the query being cached, it would be far better.
		// get list of relevant blogs
		$where_cats = trim($Blog->get_sql_where_aggregate_coll_IDs('cat_blog_ID'));

		// build query, only joining categories, if not using all.
		$sql = "SELECT LOWER(tag_name) AS tag_name, post_datestart, COUNT(DISTINCT itag_itm_ID) AS tag_count
			  FROM T_items__tag INNER JOIN T_items__itemtag ON itag_tag_ID = tag_ID";
		if( $where_cats != '1' )
		{ // we have to join the cats
			$sql .= "
			 INNER JOIN T_postcats ON itag_itm_ID = postcat_post_ID
			 INNER JOIN T_categories ON postcat_cat_ID = cat_ID";
		}
		$sql .= "
			 INNER JOIN T_items__item ON itag_itm_ID = post_ID
			 WHERE $where_cats";

if( $this->disp_params['filter_list'] )
{
    $filter_list = explode( ',', $this->disp_params['filter_list'] ) ;
    
    $filter_tags = array();
    foreach( $filter_list as $l_tag )
    {
        $filter_tags[] = '"'.$DB->escape(trim($l_tag)).'"';
    }
    
    $sql .= ' AND tag_name NOT IN ('.implode(', ', $filter_tags).')';
}

$sql .= "
     GROUP BY tag_name
     ORDER BY tag_count DESC
     LIMIT ".$this->disp_params['max_tags']; 

		$results = $DB->get_results( $sql, OBJECT, 'Get tags' );

		// pre_dump( $results );

		if( empty($results) )
		{	// No tags!
			return;
		}

		$max_count = $results[0]->tag_count;
		$min_count = $results[count($results)-1]->tag_count;
		$count_span = max( 1, $max_count - $min_count );
		$max_size = $this->disp_params['tag_max_size'];
		$min_size = $this->disp_params['tag_min_size'];
		$size_span = $max_size - $min_size;

		usort($results, array($this, 'tag_cloud_cmp'));

		echo $this->disp_params['block_start'];

		$this->disp_title();

		echo $this->disp_params['tag_cloud_start'];
		$count = 0;
		foreach( $results as $row )
		{
			if( $count > 0 )
			{
				echo $this->disp_params['tag_separator'];
			}
			// If there's a space in the tag name, quote it:
			$tag_name_disp = strpos($row->tag_name, ' ')
				? '&laquo;'.format_to_output($row->tag_name, 'htmlbody').'&raquo;'
				: format_to_output($row->tag_name, 'htmlbody');
			$size = floor( $row->tag_count * $size_span / $count_span + $min_size );

			echo $Blog->get_tag_link( $row->tag_name, $tag_name_disp, array(
				'style' => 'font-size: '.$size.'pt;',
				'title' => sprintf( T_('%d posts'), $row->tag_count ) ) );
			$count++;
		}
		echo $this->disp_params['tag_cloud_end'];

		echo $this->disp_params['block_end'];

		return true;
	}


	function tag_cloud_cmp($a, $b)
	{
		return strcasecmp($a->tag_name, $b->tag_name);
	}
}


/*
 * $Log: _coll_tag_cloud.widget.php,v $
 */
?>

10 Mar 01, 2010 23:34

*phew* figured.turns out, the roots of "localtimenow" and those other new time stuff goes deeeeeper than i thought.. i ve tried defining variables here and there but they just didnt end, and i ended up removing them.

Not a big deal if don't care about future posts (published with the date in future)


Form is loading...