Recent Topics

[2.x] display all tags

Started by on Oct 22, 2007 – Contents updated: Oct 22, 2007

Oct 22, 2007 02:13    

My b2evolution Version: 2.x

Can a "list" or "cloud" of all tags be easily generated in 2.0.2?

Similar to arcdir maybe?

Oct 22, 2007 10:19

I haven't used tags on any of my posts yet so I can't really test this, but you should be able to do something like :

<?php
$sql = 'SELECT count(*) as tag_total, tag_name FROM T_items__itemtag join ( T_items__tag ) on ( itag_tag_ID = tag_ID ) group by tag_ID';
if( $tags = $DB->get_results( $sql ) )
{
  echo '<ul>'."\n";
  foreach( $tags as $tag )
     echo '<li>'.$tag->tag_name.' ( '.$tag->tag_total.' )</li>'."\n";
  echo '</ul>';
}
?>

If that works then the answer to your question is yes ;)

¥

*edit*
Correcting code ( tag_count is tag_total :p )

and another correction ( to the table name ;) )

Oct 22, 2007 11:04

Ok, Thanks for that... though it does generate the following..
BTW, I placed the above code in index.main.php

Additional information about this error:

MySQL error!

Table 'wowfactor2.T_items__itemstag' doesn't exist(Errno=1146)

Your query:

SELECT count(*) as tag_total, tag_name

FROM T_items__itemstag join ( evo_items__tag ) on ( itag_tag_ID = tag_ID ) group by tag_ID

The database for tags is

evo_items__tag

??

Oct 22, 2007 11:05

You're getting closer ;)

This FROM T_evo_items__tag needs to either be FROM T_items__itemtag or FROM evo_items__itemtag ( whichever works )

¥

Oct 22, 2007 11:59

Bingo ...
FROM evo_items__itemtag worked.

Appreciated. How do I make the tags active links that will list the related posts ?.... or am I pushing my luck Blondie :)

Oct 22, 2007 12:02

echo '<li><a href="'.$baseurl.'?tag='.$tag->tag_name.'" title=" view all posts tagged with '.$tag->tag_name.' ">'.$tag->tag_name.' ( '.$tag->tag_total.' )</a></li>'."\n";

;)

¥

Oct 22, 2007 12:10

Your blood's worth bottling :)

Works great..

Oct 22, 2007 12:10

Only cos it has such a high alcohol content ;)

¥

Oct 23, 2007 03:27

ISSUE RESOLVED

ignore this post


Form is loading...

Free CMS – This forum is powered by b2evolution CMS, a complete engine for your website.