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
Locked
wireaudio
Registered User
Posts: 26
Joined: Fri Oct 19, 2007 8:14 am

Re: Latest Posts on site home page

Post by wireaudio » Thu Sep 04, 2008 8:08 pm

Let's see if i understand right.

You want a latest 10 active topics, NOT POSTS.

Let's get this straight:

You must understand the difference between posts and forums. If you would have last 10 posts, that means you would get the latest 10 things that people wrote, EVEN IF THEY ARE IN THE SAME TOPIC. For example, you have a topic called "topic 1". If people reply to that, let's say "REPLY1: topic 1" all the way to "REPLY10: topic 1", your last 10 posts would be the actual replies, all pointing to the same topic.
If you want the latest 10 active TOPICS, i.e. topic1, topic2... topic 10, no matter how many replies those topics get, the topic with the newst reply will be on the top.

In order for me to help you, i need a few answers from you:

1.
So i think you want the "x" latest active topics FOR EACH FORUM that you have, correct?
Or do you want the latest "x" active topics for ALL forums combined?
Are there any "hidden" forums you do not want info shown from?

2.
You also want the top "x" number of MOST ACTIVE topics.
So i'm guessing you would want the topics with the most replies, correct?

3.
Relative to the page you want the information on, where is the forum located?
Ex: If your page is in www.yoursite.com
and foum is in www.yoursite.com/forum/
the relative path would be "forum/"

4.
What format you want the topics to show in? For example, if you are planning on repeating a little table for each recent topic, i would need that table to have something to work with.
I.E.:
<table>
<tr>
<td colspan=2>title</td>
</tr>
<tr>
<td>By: user</td>
<td>On: date</td>
</tr>
</table>

(this would make a table for each topic)

Or, if you want to repeat just the rows/columns inside 1 table (<table><?php code ?></table>):
<tr>
<td colspan=2>title</td>
</tr>
<tr>
<td>By: user</td>
<td>On: date</td>
</tr>

Or if you use <div>s, give me a sample of how you want those.

I looked at your page, but im sorry, i dont really understand much... im guessing that is in hungarian or something :P And it seems that google cannot translate from hungarian to english :(

mykee
Registered User
Posts: 271
Joined: Thu Jun 07, 2007 9:46 pm

Re: Latest Posts on site home page

Post by mykee » Thu Sep 04, 2008 9:25 pm

In example page you see in boxes latest topics. One box is a one forum/category. I think like this: a category like a box, and in box I see latest topics where latest posted (anyone). Bottom of boxes you see a link to more topics. Like this:

Box1:
<forum name 1>
(topics 1 - Posted by: xyz)
(topics 29 - Posted by: hfr)
(topics 342 - - Posted by: cxr)
(topics 24 - Posted by: kkl)
<more topics...>

Box2:
<forum name 2>
(topics 13 - Posted by: sse)
(topics 27 - Posted by: lkt)
(topics 412 - Posted by: tgf)
(topics 39 - Posted by: cdf)
<more topics...>

etc...

ahuraeian
Registered User
Posts: 30
Joined: Sat Feb 16, 2008 2:26 am
Contact:

Re: Latest Posts on site home page

Post by ahuraeian » Thu Sep 11, 2008 10:52 am

hi thiscode for scroll latest post

and problem with uni code and show "?????" (my language is Persian)

Code: Select all

 <?php

    // How Many Topics you want to display?
    $topicnumber = 10;
    // Scrolling towards up or down?
    $scroll = "up";
    // Change this to your phpBB path
    $urlPath = "/forum";
 
    // Database Configuration (Where your phpBB config.php file is located)
    include 'config.php';
 
    $table_topics = $table_prefix. "topics";
    $table_forums = $table_prefix. "forums";
    $table_posts = $table_prefix. "posts";
    $table_users = $table_prefix. "users";
    $link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("Could not connect");
    mysql_select_db("$dbname") or die("Could not select database");
 
    $query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
    FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
    WHERE t.topic_id = p.topic_id AND
    f.forum_id = t.forum_id AND
    t.forum_id != 4 AND
    t.topic_status <> 2 AND
    p.post_id = t.topic_last_post_id AND
    p.poster_id = u.user_id
    ORDER BY p.post_id DESC LIMIT $topicnumber";
    $result = mysql_query($query) or die("Query failed");									
 
    print "<marquee id=\"recent_topics\" behavior=\"scroll\" direction=\"$scroll\" height=\"170\" scrolldelay=\"100\" scrollamount=\"2\" onMouseOver=\"document.all.recent_topics.stop()\" onMouseOut=\"document.all.recent_topics.start()\">
    <table cellpadding='3' cellSpacing='2' width='100%'>";
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
 
    echo  "<tr valign='top'><td><font face=\"Tahoma\" size=\"1\"><font color=\"#FFCC00\"><b><a href=\"$urlPath/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]&p=$row[post_id]#p$row[post_id]\" TARGET=\"_blank\">" .
    $row["topic_title"] .
    "</a></td></font></b><td><font face=\"Tahoma\" size=\"1\"><font color=\"#C0C0C0\"> by: <a href=\"$urlPath/memberlist.php?mode=viewprofile&u=$row[user_id]\" TARGET=\"_blank\">" .
    $row["username"] .
    "</td><td><font face=\"tahoma\" size=\"1\"><font color=\"#C0C0C0\">" .
    date('F j, Y, g:i a', $row["post_time"]) .
    "</td></tr></font>";
    }
    print "</table></marquee>";
    mysql_free_result($result);
    mysql_close($link);
    ?>

manudevil20
Registered User
Posts: 33
Joined: Fri Sep 12, 2008 12:21 am

Re: Latest Posts on site home page

Post by manudevil20 » Mon Sep 15, 2008 5:44 am

Hey there. I have a problem. I put in the code below and this is all i get. I dont know what i am doing wrong.
http://www.smokethosetires.com/aboutus.php



Code: Select all

<?
    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();
    
    /*** 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>
<?
        
    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="<?=$user->img($folder_img, $folder_alt, false, '', 'src');?>" title="<?=$user->lang[$folder_alt];?>" alt="<?=$user->lang[$folder_alt];?>" />
            <a href="<?=$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'];?>"><?=html_entity_decode($t['topic_title']);?></a><br />
    <?
    }
    ?>
</div>

manudevil20
Registered User
Posts: 33
Joined: Fri Sep 12, 2008 12:21 am

Re: Latest Posts on site home page

Post by manudevil20 » Mon Sep 15, 2008 8:42 pm

Anybody have a solution please? Thanks

sheltonjb
Registered User
Posts: 71
Joined: Tue May 06, 2008 10:30 pm

Re: Latest Posts on site home page

Post by sheltonjb » Thu Sep 18, 2008 1:48 pm

i've read through this and i'm after something similar, i'd like the latest forum post to display on my homepage too, but, i want to display the actual message which will truncate after a certain amount of characters..

for example:

"I went there the other night, it's quality but when...."

and then the whole quote would be a link to that message in the forum.

anyone implemented this?

thanks

Shelton

drankur
Registered User
Posts: 271
Joined: Sat Dec 22, 2007 4:16 am

Re: Latest Posts on site home page

Post by drankur » Thu Sep 18, 2008 2:28 pm

ahuraeian wrote:hi thiscode for scroll latest post

and problem with uni code and show "?????" (my language is Persian)

Code: Select all

 <?php

    // How Many Topics you want to display?
    $topicnumber = 10;
    // Scrolling towards up or down?
    $scroll = "up";
    // Change this to your phpBB path
    $urlPath = "/forum";
 
    // Database Configuration (Where your phpBB config.php file is located)
    include 'config.php';
 
    $table_topics = $table_prefix. "topics";
    $table_forums = $table_prefix. "forums";
    $table_posts = $table_prefix. "posts";
    $table_users = $table_prefix. "users";
    $link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("Could not connect");
    mysql_select_db("$dbname") or die("Could not select database");
 
    $query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
    FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
    WHERE t.topic_id = p.topic_id AND
    f.forum_id = t.forum_id AND
    t.forum_id != 4 AND
    t.topic_status <> 2 AND
    p.post_id = t.topic_last_post_id AND
    p.poster_id = u.user_id
    ORDER BY p.post_id DESC LIMIT $topicnumber";
    $result = mysql_query($query) or die("Query failed");									
 
    print "<marquee id=\"recent_topics\" behavior=\"scroll\" direction=\"$scroll\" height=\"170\" scrolldelay=\"100\" scrollamount=\"2\" onMouseOver=\"document.all.recent_topics.stop()\" onMouseOut=\"document.all.recent_topics.start()\">
    <table cellpadding='3' cellSpacing='2' width='100%'>";
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
 
    echo  "<tr valign='top'><td><font face=\"Tahoma\" size=\"1\"><font color=\"#FFCC00\"><b><a href=\"$urlPath/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]&p=$row[post_id]#p$row[post_id]\" TARGET=\"_blank\">" .
    $row["topic_title"] .
    "</a></td></font></b><td><font face=\"Tahoma\" size=\"1\"><font color=\"#C0C0C0\"> by: <a href=\"$urlPath/memberlist.php?mode=viewprofile&u=$row[user_id]\" TARGET=\"_blank\">" .
    $row["username"] .
    "</td><td><font face=\"tahoma\" size=\"1\"><font color=\"#C0C0C0\">" .
    date('F j, Y, g:i a', $row["post_time"]) .
    "</td></tr></font>";
    }
    print "</table></marquee>";
    mysql_free_result($result);
    mysql_close($link);
    ?>
where and how should i post this code?

Cocinoteca
Registered User
Posts: 6
Joined: Wed Sep 10, 2008 5:10 pm

Re: Latest Posts on site home page

Post by Cocinoteca » Fri Sep 19, 2008 6:01 pm

$phpbb_root_path = './forum/'; // Path to phpbb folder
I have a question. my web is in www.dominio.com and the forum is a subdomain.. how i put the path?

SheepsAway
Registered User
Posts: 5
Joined: Sat Mar 01, 2008 10:36 pm

Re: Latest Posts on site home page

Post by SheepsAway » Fri Sep 19, 2008 6:46 pm

Has anyone managed to get it working yet?

Bmlow
Registered User
Posts: 93
Joined: Mon Sep 01, 2008 1:41 pm

Re: Latest Posts on site home page

Post by Bmlow » Mon Sep 22, 2008 1:12 am

Nice, all i need to do is find what part of my index page i can insert it though.

timeforhelp
Registered User
Posts: 29
Joined: Sun Jul 13, 2008 9:17 pm

Re: Latest Posts on site home page

Post by timeforhelp » Mon Sep 22, 2008 2:09 pm

How do i get this to work on an html page,i've tried everything and no joy!

ge_rpger
Registered User
Posts: 81
Joined: Sat Jul 24, 2004 2:20 pm

Re: Latest Posts on site home page

Post by ge_rpger » Mon Sep 22, 2008 10:33 pm

OK, when I try this on a HTML page, not in the phpBB3 root folder, I get the following error.

Code: Select all

 session_begin(); 
$auth->acl($user->data); 
// Grab user preferences $user->setup(); 
/*** 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); 
?>
$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 ?> 
<?=$user->lang[$folder_alt];?> 
The page I want this to show on is located at http://root.com while the forums are located at http://root.com/phpBB3/

Any help would be great!

pinghe
Registered User
Posts: 2
Joined: Sun Oct 05, 2008 6:30 am

Re: Latest Posts on site home page

Post by pinghe » Mon Oct 06, 2008 4:09 am

Thanks. It worked on my site except it gives me the following error. Can someone tell me what the message mean and how to get rid of it?

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/session.php on line 916: Cannot modify header information - headers already sent by (output started at /home/thelogof/public_html/index.php:7)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 916: Cannot modify header information - headers already sent by (output started at /home/thelogof/public_html/index.php:7)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 916: Cannot modify header information - headers already sent by (output started at /home/thelogof/public_html/index.php:7)

sheltonjb
Registered User
Posts: 71
Joined: Tue May 06, 2008 10:30 pm

Re: Latest Posts on site home page

Post by sheltonjb » Sat Oct 25, 2008 9:44 pm

I have managed to get this working. Problem is my site uses .tpl files and the newest post file is a .php file

does anyone know how i can get the .tpl file to call in the .php forum latest posts one?

cheers

p.s. i have just noticed something else. I created a 'staff room' forum and only allowed access to the forum mods and admin. It appears that when the 'latest post' title is click, this takes you straight to the forum and message can be viewed when users shouldn't be able to.

sheltonjb
Registered User
Posts: 71
Joined: Tue May 06, 2008 10:30 pm

Re: Latest Posts on site home page

Post by sheltonjb » Tue Nov 11, 2008 12:50 pm

anyone able to shed some light for me please girls n guys?

thanks

Locked

Return to “[3.0.x] MOD Requests”