Recent Topics

1 Mar 26, 2008 17:16    

With this hack you can link your tags to any URL e.g.

http://flickr.com/photos/tags/cool+tag
http://technorati.com/tag/cool+tag
http://wikipedia.org/wiki/cool+tag
http://www.google.com/search?q=cool+tag
http://search.yahoo.com/search?p=cool+tag

Demo
http://ru.b2evo.net/demo/en/blogs/
http://www.americangirl.co.uk/

Open /inc/items/model/_item.class.php and replace the whole function, lines 2276-2331

   /**
	 * Display tags for Item
	 *
	 * @param array of params
	 * @param string Output format, see {@link format_to_output()}
	 */
	function tags( $params = array() )
	{
		$params = array_merge( array(
				'before' =>           '<div>'.T_('Tags').': ',
				'after' =>            '</div>',
				'separator' =>        ', ',
				'url'	=>			  '',
				'links' =>            true,
			), $params );

		$tags = $this->get_tags();

		if( !empty( $tags ) )
		{
			echo $params['before'];

			if( $links = $params['links'] )
			{
				$this->get_Blog();
			}

			$i = 0;
			foreach( $tags as $tag )
			{
				if( $i++ > 0 )
				{
					echo $params['separator'];
				}
				if( $links )
				{	// We want links
					if ( $params['url'] !='' )
					{
						$new_tag = str_replace(" ","+",$tag);
						echo '<a href="'.$params['url'].$new_tag.'">';
					}
					else
					{
						echo '<a href="'.$this->Blog->gen_tag_url( $tag ).'">';
					}
				}
				echo htmlspecialchars( $tag );
				if( $links )
				{
					echo '</a>';
				}
			}

			echo $params['after'];
		}
	}

How to use it...

Put this code in index.main.php next to the original tags code. Change the url link to whatever you want.

// List all tags attached to this post:
$Item->tags( array(
		'before'	=>	'<div class="bSmallPrint">'.T_('Technorati tags').': ',
		'after'		=>	'</div>',
		'separator'	=>	', ',
		'url'		=>	'http://technorati.com/tag/',
		'link'		=>	true,
	) );


Form is loading...