So... I want to contribute something to this thread. I develop my own code, because i was searching and searching and searching... and all the codes I found doesn't work fine (for me). So... I hope, this can help to some one else....
Put this code in
wordpress/wp-content/your-theme/sidebar.php
Code: Select all
<ul>
<?php
// fill with your db acces information
$d_bhost = ''; // host (localhost, 06.mysqlprovider.com)
$db_name = ''; // your data base name
$db_user = ''; // your data base user name
$db_pass = ''; // your data base password
$prefix = 'phpbb_'; // the prefix of yours pbpbb tables (phpbb_ by default)
$dir = 'http://foro.gekkotaku.com/'; // this is your foro address
$msg_display = 7; // number of displays you need
// follow my syntax for exclude your hidden or private forums...
// if you dont know how id have your hidden forums, just go to your hidden forum, check your direction bar (in your navigator, EX. firefox, explorer)
// and put atention on this: viewforum.php?f=8
// f - means forum, in this case, my hidden forum is the id - 8
$hidden_forum = "post.forum_id <> 12 AND post.forum_id <> 33 AND post.forum_id <> 36"; // the syntax: post.forum_id <> hiden-forum-id (dont forget add an AND syntax for a new condition)
// if you dont have experience on programming... dont touch this
$conn = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name,$conn);
$sql = "
SELECT forum.forum_name, post.forum_id, post.post_text, topic.topic_id, topic.topic_title, topic.topic_replies, topic.topic_last_post_id, user.username
FROM '.$prefix.'posts post
LEFT JOIN '.$prefix.'forums forum ON post.forum_id = forum.forum_id
LEFT JOIN '.$prefix.'users user ON post.poster_id = user.user_id
LEFT JOIN '.$prefix.'topics topic ON post.topic_id = topic.topic_id
WHERE
'.$hidden_forum.'
ORDER BY post.post_time DESC LIMIT $msg_display
";
$result = mysql_query($sql);
while ($rows = mysql_fetch_array($result)) {
$start = round($rows[topic_replies] / 10).'0';
$rows[post_text] = preg_replace("(\[.+?\])is",'',$rows[post_text]); // to exclude phpbb code
$rows[post_text] = substr($rows[post_text],0,80)."..."; // to limit to XX chars
echo "<li>";
echo '<a href="'.$dir.'viewtopic.php?f='.$rows[forum_id].'&t='.$rows[topic_id].'&start='.$start.'#p'.$rows[topic_last_post_id].'" title="'.$rows[post_text].'" role="visit gekkOtaku.com" target="_blank">'.$rows[username].' on: '.$rows[forum_name].' » '.$rows[topic_title].'</a>';
echo "</li>";
}
mysql_free_result($result);
mysql_close($conn);
?>
</ul>
The code display what user say and where:
User on: Foro Name > Topic Title.
Whe mouse over the link, display the tittle of link with short text from what user say.
I get the id for the forum, topic, user, post... to display in the link, also, get the title and names. With this, we show more especific information than just a topic info...
If you wana see how it works or how display the results, just go to:
http://www.gekkotaku.com
I stay connect for any question.