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)
Suggested Hosts
User avatar
Boardtalk.net
Registered User
Posts: 1243
Joined: Fri Jun 05, 2009 8:12 pm
Location: Ireland
Name: Colette
Contact:

Re: Latest Posts on site home page

Post by Boardtalk.net »

cuzzmunger wrote:... my forums is on a subdomain & home page is on the main domain...

Code: Select all

$phpbb_root_path = './forum/'; // Path to phpbb folder
Try putting up a test page in your main domain and changing the root path to your sub domain forum folder; having never tried it I dont know if it would work but worth a try.
cuzzmunger
Registered User
Posts: 7
Joined: Wed Sep 08, 2010 11:45 pm

Re: Latest Posts on site home page

Post by cuzzmunger »

I added
../forums/
It displays the unread posts but not the image & if I click on one now it goe to
http://mywebsite.com/forums/viewtopic.php?f=........

should be more like http://forums.mywebsite.com/viewtopic.php?f=........

ps. thanks for your suggestion.
I just thought I could tell the link to always open in a new window or tab?

Code: Select all

   // 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 />
    <?
    }
    ?>
cuzzmunger
Registered User
Posts: 7
Joined: Wed Sep 08, 2010 11:45 pm

Re: Latest Posts on site home page

Post by cuzzmunger »

Just using the iframe for now with _blank in the link.

Code: Select all

<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'];?>" target="_blank"><?=html_entity_decode($t['topic_title']);?></a><br />
User avatar
Boardtalk.net
Registered User
Posts: 1243
Joined: Fri Jun 05, 2009 8:12 pm
Location: Ireland
Name: Colette
Contact:

Re: Latest Posts on site home page

Post by Boardtalk.net »

Did you change path to where your forum is on the sub domain to something like this:

Code: Select all

$phpbb_root_path = './../../forums/'; // Path to phpbb folder
I dont even know if the above would work as I've no forum on a subdomain to test a solution.
if the above doesn't work try changing it a few times to either;
./../forums/
./../../../forums/
etc
It would be best to FTP to the location of your forum and take note of the root path and for each directory you have to pass through then its another /../ you have to add.
Let me know how you get on.
CloneWorks
Registered User
Posts: 18
Joined: Tue Aug 30, 2011 7:15 pm

Re: Latest Posts on site home page

Post by CloneWorks »

I am wondering if there is a way to do something like this that is table based as i need to display the last five new topics from a news section in my forums and need to display a single topic from another part of my forums.

to try and simplify:

Forum ID 1 displays last five posts in center table. Forum ID 2 displays single last post pin right table.

The code I am using for the Center Table is canceled out when using the same code in Right table.

this is the error that it results in

Code: Select all

Fatal error: Call to a member function sql_escape() on a non-object in C:\xampp\htdocs\test\includes\session.php on line 330
is there a way to do this either by editing some of the code in the PHPBB folder or is there a way to do a whole page script based on the code on the first page of this post?
jorgefms
Registered User
Posts: 43
Joined: Sun Aug 24, 2008 2:16 pm

Re: Latest Posts on site home page

Post by jorgefms »

Hi!

I'm using this code:

Code: Select all

    <?php
        define('IN_PHPBB', true);
        $phpbb_root_path = 'forum/';
        $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);
        $user->setup();
    ?>
	
    <?php
    // Number of posts and grabbing permissions
    $topic_limit = request_var('topic_limit', 10);
    $forums = array_unique(array_keys($auth->acl_getf('f_read', true)));
    // Select the last topics to which we have permissions
    $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);
    // Now let's output the content
	?>
	<font color="FFFFFF" size="4"><b>Últimas entradas no fórum:</b></font><br />
	<?
	
    while ($row = $db->sql_fetchrow($result))
    {
	?>
		<img style="border: none;margin-bottom: -10px" src="http://www.tvdospobres.com/forum/styles/aero/imageset/forum_unread.png" />
		<a href="<?=$phpbb_root_path . 'viewtopic.php?f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&p=' . $row['post_id'] . '#p' . $row['post_id'];?> " target="_blank" style="font-size: 15px; color:#FF9900"><?=utf8_decode($row['post_subject']);?></a> <font size="2" color="#FFFFFF">by <?=utf8_decode($row['username']);?></font><br />
    <?
	}
    ?>

And in Internet Explorer it shows this error:

Code: Select all

[phpBB Debug] PHP Warning: in file /includes/session.php on line 1035: Cannot modify header information - headers already sent by (output started at /var/www/clients/client4/web7/web/topicos.php:1)
[phpBB Debug] PHP Warning: in file /includes/session.php on line 1035: Cannot modify header information - headers already sent by (output started at /var/www/clients/client4/web7/web/topicos.php:1)
[phpBB Debug] PHP Warning: in file /includes/session.php on line 1035: Cannot modify header information - headers already sent by (output started at /var/www/clients/client4/web7/web/topicos.php:1)
In firefox it works fine, someone can help me?


Edit: Fixed! It has a space before <?php
flydoc
Registered User
Posts: 66
Joined: Tue Dec 13, 2011 3:49 am

Re: Latest Posts on site home page

Post by flydoc »

Maybe I spelled wrong topic, but I'll try:) I appreciate your help so far what I have edited everything works perfectly, thank you!
Namely, whether it can be set on the forum by clicking on the icon "latest post" to transfer to the first post which was released that day.
Now when I click on my latest post directly show the last post, although there are more that day.
Redsilver 3 Board Styles, Board version: 3.0.10
flydoc
Registered User
Posts: 66
Joined: Tue Dec 13, 2011 3:49 am

Re: Latest Posts on site home page

Post by flydoc »

Any?

whether it is really possible that there is no answer to my question? :shock:
Last edited by flydoc on Mon Feb 06, 2012 1:58 am, edited 2 times in total.
User avatar
stmirec
Registered User
Posts: 52
Joined: Fri Sep 02, 2011 6:40 am

Re: Latest Posts on site home page

Post by stmirec »

Hi, i used this:

Code: Select all

<?
    define('IN_PHPBB', true);
    $phpbb_root_path = './'; // 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();
?>
right after <body> tag ..

and this :

Code: Select all

 <?  
    /*** 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>
in the place i want to display the list..

It shows me only little error square on that place .. any idea how to fix this please ?

I think that my forum is instaled directly on the server .. no folder.
Last edited by stmirec on Thu Feb 02, 2012 1:50 pm, edited 1 time in total.
User avatar
stmirec
Registered User
Posts: 52
Joined: Fri Sep 02, 2011 6:40 am

Re: Latest Posts on site home page

Post by stmirec »

if someone know how what to do with this, please post.. :? i need to fix it. Thank you.
Jadenizm
Registered User
Posts: 18
Joined: Fri Jan 20, 2012 7:48 am

Re: Latest Posts on site home page

Post by Jadenizm »

Where are you guys putting this code? index.php? Can anyone help out where in index.php? Thanks in advance.
stmirec wrote:Hi, i used this:

Code: Select all

<?
    define('IN_PHPBB', true);
    $phpbb_root_path = './'; // 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();
?>
right after <body> tag ..

and this :

Code: Select all

 <?  
    /*** 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>
in the place i want to display the list..

It shows me only little error square on that place .. any idea how to fix this please ?

I think that my forum is instaled directly on the server .. no folder.

my forum is http://www.stavba-az.sk
Jadenizm
Registered User
Posts: 18
Joined: Fri Jan 20, 2012 7:48 am

Re: Latest Posts on site home page

Post by Jadenizm »

In all of these 9 pages, no one has actually specified where these mods go, which files need the editing... Am I crazy? Am I the only one who's noticed this??
pitibonom
Registered User
Posts: 57
Joined: Thu Feb 09, 2012 3:59 pm

Re: Latest Posts on site home page

Post by pitibonom »

nope you're not !
Every coder here seem to assume that ppl reading are not noobs as you & me are.

I'm sorry to ask but, as i found nowhere in help/faq/docs/forums what files do what....

where should those code additions take place please ?

thanks in advance for kind answers ;)
wefer
Registered User
Posts: 7
Joined: Wed Jul 18, 2007 10:07 pm

Re: Latest Posts on site home page

Post by wefer »

Jadenizm wrote:In all of these 9 pages, no one has actually specified where these mods go, which files need the editing... Am I crazy? Am I the only one who's noticed this??
You've to edit the page you want to display latest post. For example, it's worth if you use a custom index page for your forum, not the standard index.php that comes with phpbb. Remember that typically it must be an PHP page.

For example, in my forum I've made a custom index page called index.php, and the original index.php has been renamed to index2.php.
kazooki
Registered User
Posts: 3
Joined: Tue Jul 17, 2012 12:50 pm

Re: Latest Posts on site home page

Post by kazooki »

Hi Guys,

Joined the forum simply because of this post and am no PHP expert (as you can probably see from the code below) so please be gentle :)

I used the include method that was posted way back at the top of page 3 and it works perfectly, however .. being a fussy mess I decided that I wanted to style the latest posts output and not have them in tables so I altered the code to this:

Code: Select all

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

    $topic_limit = request_var('topic_limit', 5);
    $forums = array_unique(array_keys($auth->acl_getf('f_read', true)));

    $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);
	
	
	echo '<ul class="arrows">';
	
		while ($row = $db->sql_fetchrow($result))
		{
			$url = generate_board_url() . "/viewtopic.{$phpEx}?f={$row['forum_id']}&t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}";
			
			echo '<li>';
			echo '<a target="_blank" href="' . $url .'">' . $row['post_subject'] . '</a>';
			echo '</li>';
		}
	
	echo '</ul>';
	
?>
Now it all looks very yummy indeed on the page however, when I click a post listing, it gives an invalid URL as it uses http://www.domainname.comforum/viewtopi ... t=3&p=3#p3 .. there is a '/' missing from the URL.
I've searched through the code and I can't seem to see why :(

Any ideas?

Thanks :)
Locked

Return to “[3.0.x] MOD Requests”