Recent Topics

1 Sep 05, 2008 20:32    

My b2evolution Version: 2.4.x

I'm just learning b2 and can't determine if / how this would be done.

I want a page located at mysite.com/tags to list all the tags I use.

So, how would I do the following:

1) Create a custom URL of mysite.com/tags

2) Pull all the tags used

Thanks

2 Sep 06, 2008 01:19

Welcome to the forum.

Create new file /conf/_config_TEST.php with the following code

function generate_tags_list( $form = true, $class = 'tags_list' )
{
	global $DB, $Blog, $cache_tags;
	
	if( empty($cache_tags) )
	{
		$cache_tags = $DB->get_col(
				'SELECT tag_name
				FROM T_items__itemtag INNER JOIN T_items__tag ON itag_tag_ID = tag_ID
				ORDER BY tag_name', 0, 'Get all tags' );
		
		if( is_array($cache_tags) )
			$cache_tags = array_unique($cache_tags);
	}
	
	if( empty($cache_tags) )
		return false;

	$r = array();
	foreach( $cache_tags as $tag )
	{	
		if( $form )
		{
			$r[] = '<option value="'.$tag.'">'.$tag.'</option>';
		}
		else
		{
			$r[] = '<li><a href="'.$Blog->gen_blogurl().'?tag='.$tag.'">'.$tag.'</a></li>';
		}
	}

	if( !empty($r) )
	{
		if( $form )
		{
			return "\n\n".'<select name="tag"><option value="">'.T_('All').'</option>'.implode( "\n", $r ).'</select>';
		}
		else
		{
			return "\n\n".'<ul class="'.$class.'">'.implode( "\n", $r ).'</ul>';
		}
	}	
	return false;
}

This function will build a list of all tags assigned to posts, and display it in 2 ways.

1. Options menu

$Form = & new Form( $Blog->gen_blogurl(), NULL, 'post' );
$Form->begin_form();
echo generate_tags_list();
$Form->submit( array( '', T_('Search'), 'ActionButton' ) );
$Form->end_form();

2. Tags List

echo generate_tags_list( false );

3 Sep 06, 2008 18:41

Thanks much.

What URL would I use to see that page?


Form is loading...