[phpBB Debug] error

Discussion forum for MOD Writers regarding MOD Development.
SCChirp
Registered User
Posts: 23
Joined: Sat Jun 23, 2012 8:54 am

[phpBB Debug] error

Post by SCChirp »

Hey everyone,
Trying to get forum posts to an external page and I'm getting this:

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4668: Cannot modify header information - headers already sent by (output started at /home/content/72/7095572/html/tts-demo/index.php:14)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4670: Cannot modify header information - headers already sent by (output started at /home/content/72/7095572/html/tts-demo/index.php:14)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4671: Cannot modify header information - headers already sent by (output started at /home/content/72/7095572/html/tts-demo/index.php:14)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4672: Cannot modify header information - headers already sent by (output started at /home/content/72/7095572/html/tts-demo/index.php:14)
The forum posts are actually displaying, but that error is displayed above them. I have extremely limited php knowledge and used this guide to set up what I have so far: http://www.cricketmx.com/articles/read/ ... in-phpbb3/

That's basically what I'm trying to do though. And here is how I have my site setup...

Right now it's just a demo and work in progress so I have it all in a sub-directory.

Root/tts-demo/forum/

My index.php(homepage) is in tts-demo, and all of the phpbb software is in forum. The page I'm trying to get the forum posts to display on is index.php, which again is in tts-demo.

I created the php file home.php like the guide says, and have the included code in it. I use a php include to get the code to my index page, here is what it looks like:

Code: Select all

<?php 
include 'home.php';
?>
I hope that's enough information!

Thanks in advance for any help. Like I said, I really have limited knowledge of php and mySQL!

Thanks again!



EDIT:
Since this thread has been approved I've played around with this more but I still don't get it. I've found loads of threads discussing this but I still can't figure it out. What I'm wanting to do is just pull topics to a html(or php) file that is outside of the forum folder. What all is involved with this? I have been able to get the posts to go to their own php page, as example... home.php in the above example will display the posts without any problems. But when I try to use that on my index.php (in the same directory), it doesn't work. =/

Thanks again :D Just trying to clarify as much as possible!
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52126
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [phpBB Debug] error

Post by Brf »

SCChirp wrote: (output started at /home/content/72/7095572/html/tts-demo/index.php:14)
The phpBB sessions code goes at the very top of your page, before any HTML output.
SCChirp
Registered User
Posts: 23
Joined: Sat Jun 23, 2012 8:54 am

Re: [phpBB Debug] error

Post by SCChirp »

What part is the session code?

Code: Select all

<?php
/*
* home.php
* Description: example file for displaying latest posts and topics
* by battye (for phpBB.com MOD Team)
* September 29, 2009
*/

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');
All of that? Do I need to close it with ?> ? Does that go before even the DOCTYPE declaration?

Then I use the rest of the code where I want the topics to be displayed?
Thanks! :)
SCChirp
Registered User
Posts: 23
Joined: Sat Jun 23, 2012 8:54 am

Re: [phpBB Debug] error

Post by SCChirp »

Also, another question, what does the "footer" portion of that code do?

Code: Select all

page_header('External page');

$template->set_filenames(array(
'body' => 'external_body.html'
));

page_footer();
?>
I currently have the "sessions" code above even my HTML declaration. Then I have this code where I want the posts to display:

Code: Select all

		<?php
		$search_limit = 5;

$posts_ary = array(
'SELECT' => 'p.*, t.*, u.username, u.user_colour',

'FROM' => array(
POSTS_TABLE => 'p',
),

'LEFT_JOIN' => array(
array(
'FROM' => array(USERS_TABLE => 'u'),
'ON' => 'u.user_id = p.poster_id'
),
array(
'FROM' => array(TOPICS_TABLE => 't'),
'ON' => 'p.topic_id = t.topic_id'
),
),

'WHERE' => $db->sql_in_set('t.forum_id', array_keys($auth->acl_getf('f_read', true))) . '
AND t.topic_status <> ' . ITEM_MOVED . '
AND t.topic_approved = 1',

'ORDER_BY' => 'p.post_id DESC',
);

$posts = $db->sql_build_query('SELECT', $posts_ary);

$posts_result = $db->sql_query_limit($posts, $search_limit);

while( $posts_row = $db->sql_fetchrow($posts_result) )
{
$topic_title = $posts_row['topic_title'];
$post_author = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_colour']);
$post_date = $user->format_date($posts_row['post_time']);
$post_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $posts_row['post_id'] . "#p" . $posts_row['post_id']);

$post_text = nl2br($posts_row['post_text']);

$bbcode = new bbcode(base64_encode($bbcode_bitfield)); 
$bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);

$post_text = smiley_text($post_text);

$template->assign_block_vars('announcements', array(
'TOPIC_TITLE' => censor_text($topic_title),
'POST_AUTHOR' => $post_author,
'POST_DATE' => $post_date,
'POST_LINK' => $post_link,
'POST_TEXT' => censor_text($post_text),
));
} ?>
But nothing appears. If I add the footer portion to the above block of code I get the same error that I originally started out with.
SCChirp
Registered User
Posts: 23
Joined: Sat Jun 23, 2012 8:54 am

Re: [phpBB Debug] error

Post by SCChirp »

OK, I got the posts to display, but now I'm having another issue. Everything below the code is cut off =/ Literally, the rest of my page just doesn't display anymore. I think it has something to do with the footer portion of the code.

I got the posts to display without any codes by removing this line:

Code: Select all

page_header('External page');
I'm not even totally sure what that line does.

There are several guides to do this kind of thing, but they all assume the user has some knowledge, so I'm having a hard time understanding exactly what the code I'm using does!
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52126
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [phpBB Debug] error

Post by Brf »

The sessions code, which belongs at the top, you identified correctly. If you are not using phpBB's header,footer, and style, you are better-off using echos to display your posts, rather than trying to use the template system. The page_header fills the title block and some variables which appear on every normal phpBB page. You do not need it. The page_footer generates the templated page, and exits from the PHP. You do not need that either.
SCChirp
Registered User
Posts: 23
Joined: Sat Jun 23, 2012 8:54 am

Re: [phpBB Debug] error

Post by SCChirp »

Thanks for reply, Brf.
How can I use echos to display the posts?

So am I better off just now using the above block of code at all?
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52126
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [phpBB Debug] error

Post by Brf »

Take the HTML code from your external_body.html and just echo it.
But do not echo the template tags, use the variables instead.

Like:

Code: Select all

echo '<td>' . $post_date . '</td>';
SCChirp
Registered User
Posts: 23
Joined: Sat Jun 23, 2012 8:54 am

Re: [phpBB Debug] error

Post by SCChirp »

So, how would I need to modify my code to just use the echos?

Code: Select all

<?php

$search_limit = 5;

$posts_ary = array(
        'SELECT'    => 'p.*, t.*, u.username, u.user_colour',
    
        'FROM'      => array(
            POSTS_TABLE     => 'p',
        ),
    
        'LEFT_JOIN' => array(
            array(
                'FROM'  => array(USERS_TABLE => 'u'),
                'ON'    => 'u.user_id = p.poster_id'
            ),
            array(
                'FROM'  => array(TOPICS_TABLE => 't'),
                'ON'    => 'p.topic_id = t.topic_id'
            ),
        ),
    
        'WHERE'     => $db->sql_in_set('t.forum_id', array_keys($auth->acl_getf('f_read', true))) . '
                        AND t.topic_status <> ' . ITEM_MOVED . '
                         AND t.topic_approved = 1',
    
        'ORDER_BY'  => 'p.post_id DESC',
    );
    
	$posts = $db->sql_build_query('SELECT', $posts_ary);

	$posts_result = $db->sql_query_limit($posts, $search_limit);

      while( $posts_row = $db->sql_fetchrow($posts_result) )
      {
         $topic_title       = $posts_row['topic_title'];
         $post_author       = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_colour']);
         $post_date          = $user->format_date($posts_row['post_time']);
         $post_link       = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $posts_row['post_id'] . "#p" . $posts_row['post_id']);

         $post_text = nl2br($posts_row['post_text']);

         $bbcode = new bbcode(base64_encode($bbcode_bitfield));         
         $bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);

         $post_text = smiley_text($post_text);
		 
			
         $template->assign_block_vars('announcements', array(
		 	
         'TOPIC_TITLE'        => censor_text($topic_title),
         'POST_AUTHOR'       => $post_author,
         'POST_DATE'       => $post_date,
         'POST_LINK'       => $post_link,
         'POST_TEXT'         => censor_text($post_text),

         ));
      }
	  
	
    $template->set_filenames(array(
        'body' => 'external_body.html'
    ));
	
	$template->display('body');
	

?>
Currently external_body.html doesn't even effect the displayed posts on my web-site, I can even delete the file and it still displays the same :|
User avatar
RMcGirr83
Former Team Member
Posts: 21581
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: [phpBB Debug] error

Post by RMcGirr83 »

Currently external_body.html doesn't even effect the displayed posts on my web-site, I can even delete the file and it still displays the same
That's because it is using the cached version of the file.
Appreciate the extensions/mods/support then buy me a beerImage
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52126
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [phpBB Debug] error

Post by Brf »

SCChirp wrote:So, how would I need to modify my code to just use the echos?
I wouldnt know, without knowing what HTML you are using in your external_body.html to display the posts.
SCChirp
Registered User
Posts: 23
Joined: Sat Jun 23, 2012 8:54 am

Re: [phpBB Debug] error

Post by SCChirp »

Thank you guys! I got it working with echos! Was stuck on this for 3 days, hah. So happy :D

However, 2 more quick questions, hopefully easy ones. First I want my topic titles to be links to the topic on the actual forums. How can I do this? This is the current code I use for the title:

Code: Select all

echo '<div class="newsbox"><h3>' . $topic_title . '</h3>';
Obviously I know it needs to be wrapped in <a href>, but what can I do to make sure the url is generated correctly?

The second question is kind of relative to the first one. I'd like to add a link to the comments for the topic, I know the same link as the title will suffice, but is there an anchor in the forum code that will allow me to link directly to where they begin?

Thanks again for all the help guys :)
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52126
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [phpBB Debug] error

Post by Brf »

$post_link is your URL.
SCChirp
Registered User
Posts: 23
Joined: Sat Jun 23, 2012 8:54 am

Re: [phpBB Debug] error

Post by SCChirp »

How do you insert the variable into a link?

I tried this(don't laugh :P)

Code: Select all

echo '<div class="newsbox"><h3><a href="$post_link">' . $topic_title . '</a></h3>';
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52126
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [phpBB Debug] error

Post by Brf »

close

Code: Select all

echo '<div class="newsbox"><h3><a href=" ' . $post_link . '">' . $topic_title . '</a></h3>';
Locked

Return to “[3.0.x] MOD Writers Discussion”