Recent Topics

1 Feb 10, 2010 20:46    

My b2evolution Version: Not Entered

I think after 6 months of trying I have figured out how to do this. I am REALLY hoping someone will help me the last few steps. I have it working but it isn't pulling the most recent and I can't figure out why. It is pulling some but not the most recent posts.

This is a modified version of some code I found and it seems to work, just needs to be tweaked!

Also I have no idea how to make this pretty, it is all italicized? Any clue how to change that?

Sorry not a php coder...surprised I got this to work!

Here's the code

<?php
require_once("connect.php");
$number=0;
$forumQ=mysql_query("SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_time, t.topic_first_poster_name, f.forum_name
FROM (phpbb_topics t)
LEFT JOIN phpbb_forums f ON (t.forum_id = f.forum_id)
WHERE t.topic_approved=1
ORDER BY topic_last_post_time
LIMIT 5");
while($forumRow = mysql_fetch_row($forumQ)){
$number++;
$forumRow[3]=date('D M d, Y g:i a', $forumRow[3]);
echo $number."<a href=forum/viewtopic.php?f=".$forumRow[1]."&t=".$forumRow[0].">".$forumRow[2]."</a> posted in ".$forumRow[5]." by ".$forumRow[4]." on ".$forumRow[3]."<br>";
}
?>

Any help would be greatly appreciated!

2 Feb 11, 2010 16:57

this script worked for me :

<?php
    /**
    * newest_posts - raw dump of newest posts from forum
    *
    * @copyright (c) 2008 ameeck / Vojtech Vondra - phpBB.cz
    * @license http://opensource.org/licenses/gpl-license.php GNU Public License
    */
    define('IN_PHPBB', true);
    $phpbb_root_path = '../subdomains/forums/public_html/';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();

    // Number of posts and grabbing permissions
    // Pocet príspevku pro zobrazení a oprávnení
    $topic_limit = request_var('topic_limit', 17);
    if( $forums = array_unique(array_keys($auth->acl_getf('f_read', true))) )
    {
	    // Select the last topics to which we have permissions
	    // Vybrat poslední témata ke kterým máme oprávnení
	    $sql = 'SELECT p.topic_id,p.post_id, p.forum_id, p.post_subject, p.post_time, u.username
	                    FROM ' . POSTS_TABLE . ' p , ' . USERS_TABLE . ' u
	                    WHERE post_approved = 1
	                        AND ' . $db->sql_in_set('forum_id', $forums) . '
	                        AND u.user_id = p.poster_id
	                    ORDER BY post_time DESC
	                    LIMIT 0,' . $topic_limit;
	    $result = $db->sql_query($sql);

	    // Proper header since output not buffered
	    // Poslat hlavicky pro správné kódování, protože výpis obsahu je postupný
	    header('Content-Type: text/html; charset=utf-8');


	// Now let's output the content
	// A ted vypsat obsah
	echo '';
	while ($row = $db->sql_fetchrow($result))
	{
	    $url = generate_board_url() . "/viewtopic.{$phpEx}?f={$row['forum_id']}&amp;t={$row

	['topic_id']}&amp;p={$row['post_id']}#p{$row['post_id']}";
	    echo '<li><a target="_top" href="' . $url . '">' . $row['post_subject'] . '</a> from

	' . $row['username'] . ' </li>';
	}
	echo '';
    }
?>

¥


Form is loading...