Latest Posts on site home page

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Scam Warning
Embraer195
Registered User
Posts: 4
Joined: Thu Jan 03, 2008 7:06 pm

Latest Posts on site home page

Post by Embraer195 »

Is there a code for V3 that I can add to have the latest forum postings shown on the site home page? I've seen it on another website and I'm intrigued to have it on mine. If anyone can help me?

I tried 'fetch all' but I'm having difficulties!

Many thanks.

J.
xDazedx
Registered User
Posts: 362
Joined: Sat Aug 21, 2004 11:42 pm

Re: Latest Posts on site home page

Post by xDazedx »

I am looking for this as well. I had it on phpbb2 but not on v3.
zippolah
Registered User
Posts: 1
Joined: Fri Mar 21, 2008 9:50 am

Re: Latest Posts on site home page

Post by zippolah »

im also looking for this same mod. any help or link to mods would be great thnx
demo2008
Registered User
Posts: 9
Joined: Thu Mar 20, 2008 6:01 am

Re: Latest Posts on site home page

Post by demo2008 »

search for NV recent topics
Embraer195
Registered User
Posts: 4
Joined: Thu Jan 03, 2008 7:06 pm

Re: Latest Posts on site home page

Post by Embraer195 »

'NV Recent Topic' is for the actual forum though isn't it? I wanted the code to add to a non-forum webpage so it would draw more visitors to the forum direct from the front page.
xDazedx
Registered User
Posts: 362
Joined: Sat Aug 21, 2004 11:42 pm

Re: Latest Posts on site home page

Post by xDazedx »

Embraer195 you and I are on the same page.

I think that mod just lists recent topics on the forum page. I would like to put a small block on a side panel of my main site for recent posts in the forum. I had this before as a scrolling marquee. Helped bring people to the forum.
Gnagy08
Registered User
Posts: 19
Joined: Thu Mar 20, 2008 3:33 am

Re: Latest Posts on site home page

Post by Gnagy08 »

It would be nice to have a it for HTML since my main page is HTML format.
Vinyard_X43q
Registered User
Posts: 19
Joined: Wed Jun 06, 2007 8:14 am

Re: Latest Posts on site home page

Post by Vinyard_X43q »

Here is a cleaned up version of what I use on my website.

This must be placed at the top of your page.

Code: Select all

<?php
    define('IN_PHPBB', true);
    $phpbb_root_path = './forum/'; // Path to phpbb folder
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
    include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

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

    // Grab user preferences
    $user->setup();
?>
Place this where you want the topic links to appear.

Code: Select all

<?php
    /*** phpBB3 - Last Active Topics System ***/
    //Show last x topics
    define('TOPICS_LIMIT',10);

    // Create arrays
    $topics = array();
    
    // Get forums that current user has read rights to.
    $forums = array_unique(array_keys($auth->acl_getf('f_read', true)));
    
    // Get active topics.
    $sql="SELECT *
    FROM " . TOPICS_TABLE . "
    WHERE topic_approved = '1' AND " . $db->sql_in_set('forum_id', $forums) . "
    ORDER BY topic_last_post_time DESC";
    $result = $db->sql_query_limit($sql,TOPICS_LIMIT);
    while ($r = $db->sql_fetchrow($result))
    {
        $topics[] = $r;
    }
   $db->sql_freeresult($result);
?>
<div>
<?php
        
    foreach($topics as $t)
    {
        // Get folder img, topic status/type related information
        $topic_tracking_info = get_complete_topic_tracking($t['forum_id'], $t['topic_id']);
        $unread_topic = (isset($topic_tracking_info[$t['topic_id']]) && $t['topic_last_post_time'] > $topic_tracking_info[$t['topic_id']]) ? true : false;
        $folder_img = $folder_alt = $topic_type = '';
        topic_status($t, $t['topic_replies'], $unread_topic, $folder_img, $folder_alt, $topic_type);
        
        // output the link
        ?>
            <img style="vertical-align: text-bottom" src="<?php echo $user->img($folder_img, $folder_alt, false, '', 'src');?>" title="<?php echo $user->lang[$folder_alt];?>" alt="<?php echo $user->lang[$folder_alt];?>" />
            <a href="<?php echo $phpbb_root_path . 'viewtopic.php?f=' . $t['forum_id'] . '&t=' . $t['topic_id'] . '&p=' . $t['topic_last_post_id'] . '#p' . $t['topic_last_post_id'];?>"><?php echo html_entity_decode($t['topic_title']);?></a><br />
    <?
    }
    ?>
</div>
Here is a demo: https://www.vnetgaming.net/activetopics_clean.php
Hope it's what you guys are looking for. :)
Last edited by Vinyard_X43q on Fri Feb 14, 2014 9:33 pm, edited 7 times in total.
Embraer195
Registered User
Posts: 4
Joined: Thu Jan 03, 2008 7:06 pm

Re: Latest Posts on site home page

Post by Embraer195 »

Works like a charm, Vinyard!

Many thanks for your efforts I really appreciate it! :D
Vinyard_X43q
Registered User
Posts: 19
Joined: Wed Jun 06, 2007 8:14 am

Re: Latest Posts on site home page

Post by Vinyard_X43q »

Glad to hear its working great for you. :)
saultw
Registered User
Posts: 1
Joined: Sun Mar 23, 2008 10:45 am

Re: Latest Posts on site home page

Post by saultw »

I would like to ask how to change the hot TOPICS
Vinyard_X43q
Registered User
Posts: 19
Joined: Wed Jun 06, 2007 8:14 am

Re: Latest Posts on site home page

Post by Vinyard_X43q »

What exactly do you mean by "hot topics"?
pbcd2000
Registered User
Posts: 7
Joined: Mon Mar 24, 2008 8:33 pm

Re: Latest Posts on site home page

Post by pbcd2000 »

This works fine for me but I would like to be able to show all the latest posts to unregistered users as well, not just related to a persons logged in permissions. When an unregistered user clicks on such a post phpBB asks them to register anyway so that would be good for my purposes. A sort of 'see what your missing' type of system.

How would I change the above code to ignore a users permissions and show all posts?
pbcd2000
Registered User
Posts: 7
Joined: Mon Mar 24, 2008 8:33 pm

Re: Latest Posts on site home page

Post by pbcd2000 »

Cancel my last, i changed the code from

Code: Select all

$sql = 'SELECT p.post_id, p.topic_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);
to

Code: Select all

$sql = 'SELECT p.post_id, p.topic_id, p.forum_id, p.post_subject, p.post_time, u.username
                    FROM ' . POSTS_TABLE . ' p , ' . USERS_TABLE . ' u
                    WHERE post_approved = 1
                        AND u.user_id = p.poster_id
                    ORDER BY post_time DESC
                    LIMIT 0,' . $topic_limit;
    $result = $db->sql_query($sql);
That seems to do the trick not full understanding what I have done but I think I have ignored any reference to an array that contains a list of permitted forums for the current user.
Vinyard_X43q
Registered User
Posts: 19
Joined: Wed Jun 06, 2007 8:14 am

Re: Latest Posts on site home page

Post by Vinyard_X43q »

The code you removed was an array of forums the current user has read right to. In order for any topics to appear guest users must have read rights to some forums or else nothing will appear.

Return to “[3.0.x] MOD Requests”