Recent Topics

1 Dec 08, 2006 22:56    

I cannot figure out what is causing this error message:

Warning: Cannot modify header information - headers already sent by (output started at /home/cheever/public_html/index.php:11) in /home/cheever/public_html/Blogs/inc/MODEL/sessions/_session.class.php on line 196

I am trying to insert a few of the most recent blog posts on a "home" page, using this in the home page (index.php):

<?php 
include('/home/cheever/public_html/Blogs/index_insert.php');   
?>

The index_insert.php file looks like this:

<?php
require_once dirname(__FILE__).'/conf/_config.php';
require_once $inc_path.'_main.inc.php';
$blog = 1;      // All blog
$timestamp_max = 'now'; 
$posts= 5; // Show 5 posts
$skin="insert"; // Skin the insert
require $inc_path.'_blog_main.inc.php';
?>

I have tried tracing down what's causing the problem. This is what is at line 196 of _session.class.php:

			// Set a cookie valid for ~ 10 years:
			setcookie( $cookie_session, $this->ID.'_'.$this->key, time()+315360000, $cookie_path, $cookie_domain );

			$Debuglog->add( 'ID (generated): '.$this->ID, 'session' );
			$Debuglog->add( 'Cookie sent.', 'session' );
		}


_session.class.php is called by _main.inc.php. I tried deleting the "require_once $inc_path.'_main.inc.php';" statement from index_insert.php, but _main.inc.php is also called by _blog_main.inc.php. I need _blog_main.inc.php to fetch the posts.

I had this working on several sites before the new b2evo version. I have tried eliminating whitespace (mentioned in a couple other threads). Banging my skull against the wall has also failed to yield results.

I just cannot figure it out.

2 Dec 09, 2006 00:59

Displaying starts in the skin, if your skin is say the 'custom' skin, then it is /blogs/skins/custom/_main.php were display starts.

What is happening is you are doing display before b2evolution is finished loading (in more exact terms, modifying the headers appropriately).

3 Dec 09, 2006 04:54

balupton wrote:

Displaying starts in the skin, if your skin is say the 'custom' skin, then it is /blogs/skins/custom/_main.php were display starts.

What is happening is you are doing display before b2evolution is finished loading (in more exact terms, modifying the headers appropriately).

Thanks for the help.

How can I make sure b2evo has finished loading before displaying?

I thought the problem was the the headers for index.php get sent and then _session.class.php tries to drop a cookie - another header.

I am doing this - in general - the way I have done it before.

I have created (as I did for earlier versions) a skin for the insert. I can post the _main.php for that skin, if that would help. In fact, just in case, here it is:

<?php
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );


	// ------------------------------------ START OF POSTS ----------------------------------------
	$MainList = & new ItemList( $blog,	 $show_statuses, '', $m, $w, '', array(), $author, $order, $orderby, $posts, '', '', '', '', '', '', '', $unit, $timestamp_min, $timestamp_max );

	if( isset($MainList) ) $MainList->display_if_empty(); // Display message if no post
?>

        <!-- messages -->
        <?php if( isset($MainList) ) while( $Item = $MainList->get_item() )
	{ ?>
        <div class="date_headline">
          <?php $MainList->date_if_changed(); ?>
        </div>
        <!-- date headline -->
<div class="entry">
        <?php locale_temp_switch( $Item->locale ); // Temporarily switch to post locale ?>
        <h3 class="entry_title">
          <?php $Item->title(); ?>
        </h3>
        <div class="entry_info_top">
          <div class="entry_date">
            <?php $Item->issue_date() ?>
          </div>
          <div class="entry_time"> @
            <?php $Item->issue_time(); ?>
          </div>
          <div class="entry_author">
            <?php $Item->author();?>
          </div>
		  <div class="entry_permalink">
            <?php $Item->permanent_link('#text#') ?>
          </div>
          <div class="entry_edit">
            <?php $Item->edit_link('','','edit') // Link to backoffice for editing ?>
          </div>
          <!-- entry edit -->
        </div>
        <!-- entry info top -->
        <div class="entry_text">
          <?php $Item->content(); ?>
        </div>
        <div class="entry_more">
          <?php link_pages() ?>
        </div>
        <div class="entry_info_bottom">
          <div class="entry_status">
            <?php $Item->status( 'raw' ) ?>
          </div>
          <div class="entry_lang">
            <?php $Item->lang() ?>
          </div>
          <div class="entry_category">
            <?php $Item->categories();?>
          </div>
          <div class="entry_wordcount">
            <?php $Item->wordcount();?>
            words</div>
          <div class="entry_views">
            <?php $Item->views();?>
          </div>
          <div class="entry_localeflag">
            <?php locale_flag( $Item->locale, 'h10px' );?>
          </div>
          <div class="entry_maillink">
            <?php $Item->msgform_link( $Blog->get('msgformurl'), '', '', 'e-mail author' );?>
          </div>
          <div class="entry_comment">
            <?php $Item->feedback_link( 'comments' ) // Link to comments ?>
          </div>
          <div class="entry_trackbacks">
            <?php $Item->feedback_link( 'trackbacks') // Link to trackbacks ?>
          </div>
          <div class="entry_pingbacks">
            <?php $Item->feedback_link( 'pingbacks') // Link to trackbacks ?>
          </div>
        </div>
        <!-- entry info bottom -->
        <div class="entry_feedback_form">
          <?php
			// ------------- START OF INCLUDE FOR COMMENTS, TRACKBACK, PINGBACK, ETC. -------------
			$disp_comments = 1;					// Display the comments if requested
			$disp_comment_form = 1;			// Display the comments form if comments requested
			$disp_trackbacks = 1;				// Display the trackbacks if requested

			$disp_trackback_url = 1;		// Display the trackbal URL if trackbacks requested
			$disp_pingbacks = 1;				// Display the pingbacks if requested
			require( dirname(__FILE__).'/_feedback.php' );
			// ---------------- END OF INCLUDE FOR COMMENTS, TRACKBACK, PINGBACK, ETC. ----------------

			locale_restore_previous();	// Restore previous locale (Blog locale)
		?>
        </div>
        <!-- entry feedback form -->
        <div class="entry_rdf">
          <?php $Item->trackback_rdf() // trackback autodiscovery information ?>
        </div>
        <!-- entry rdf -->
		</div> <!-- entry  -->
        <?php
	} // ---------------------------------- END OF POSTS ------------------------------------
	?>
        <div class="nav_next_page">
          <?php posts_nav_link(); ?>
          <?php
			// previous_post( '<p class="center">%</p>' );
			// next_post( '<p class="center">%</p>' );
		?>
        </div>
        <!-- nav next page -->
        <div class="entry_form_requested">
          <?php
	// ---------------- START OF INCLUDES FOR LAST COMMENTS, ETC. ----------------
	switch( $disp )
	{
		case 'comments':
			// this includes the last comments if requested:
			require( dirname(__FILE__).'/_lastcomments.php' );
			break;

		case 'arcdir':
			// this includes the archive directory if requested
			require( dirname(__FILE__).'/_arcdir.php');
			break;

		case 'profile':
			// this includes the profile form if requested
			require( dirname(__FILE__).'/_profile.php');
			break;

		case 'msgform':
			// this includes the email form if requested
			require( dirname(__FILE__).'/_msgform.php');
			break;

		case 'subs':
			// this includes the subscription form if requested
			require( dirname(__FILE__).'/_subscriptions.php');
			break;
	}
	// ------------------- END OF INCLUDES FOR LAST COMMENTS, ETC. -------------------
?>
        </div>
        <!-- entry form requested -->

4 Dec 09, 2006 04:59

Sorry i misread what you were intending to do, could you post the contents of /home/cheever/public_html/index.php

5 Dec 09, 2006 05:14

You bet. Thanks again.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cheever Family</title>
<link rel="stylesheet" href="Assets/common.css" type="text/css" />
<link rel="stylesheet" href="Assets/insert.css" type="text/css" />
</head>
<body> 
<div id="masthead"> 
  <img src="/Assets/title1.jpg" alt='' width="561" height="93" />
</div> 
<div id="content"> 
  <div id="breadCrumb"> 
  </div> 
 <!-- 	Begin contents inserted from blogs -->
<?php 
include('/home/cheever/public_html/Blogs/index_insert.php');   
?>
      <!-- 	End contents -->


  <div class="story"></div> 
</div> 
<!--end content --> 
<div id="navBar"> 

  <div class="relatedLinks"> 
    <h3>Down Under 2007</h3> 
    <ul> 
      <li><a href="../Blogs">Blog</a></li> 
      <li><a href="#">Photos</a></li> 
 
    </ul> 
  </div> 
 
</div> 
<!--end navBar div --> 
<div id="siteInfo"> 
  <a href="#">About Us</a> | <a href="#">Contact Us</a> | &copy;2006
  The Cheever Family
</div> 
</body>
</html>

It's here, too, http://cheeverfamily.net

6 Dec 09, 2006 05:18

Sorry by contents i meant source code.

7 Dec 09, 2006 14:14

I think all that banging of my head must have caused damage, because I'm not sure which source code to post. Here's the php code in index.php:

<?php
include('/home/cheever/public_html/Blogs/index_insert.php');   
?> 

It refers to index_insert.php posted above.

8 Dec 09, 2006 14:17

Well... if thats all of it, then your server is crazy as it thinks there is a line 7 in it ;)

Warning: Cannot modify header information - headers already sent by (output started at /home/cheever/public_html/index.php:7) in /home/cheever/public_html/Blogs/inc/MODEL/sessions/_session.class.php on line 196

9 Dec 09, 2006 14:32

I can't figure out why it say line 7. That line is this stylesheet link:

<link rel="stylesheet" href="Assets/insert.css" type="text/css" />

When I remove it, same error but line 10.

I think it is unlikely that the server is goofed up. I run a bunch of php things on it, without problems.

BTW, I am not wedded to this code. I'd be happy to do the insert another way. This is just the way I used (and am using on several other sites with older b2evo versions.) Eventually, I'll need to update b2evo on all of those.

10 Dec 09, 2006 14:41

I can't figure out why it say line 7. That line is this stylesheet link:

<link rel="stylesheet" href="Assets/insert.css" type="text/css" />

When I remove it, same error but line 10.

Exactly!!! because <link is starting display!

Could you post the parts of the code say lines 1-10.

11 Dec 09, 2006 15:10

Thanks for hanging in there. Here's 5-21:

<title>Cheever Family</title>
<link rel="stylesheet" href="Assets/common.css" type="text/css" />
<link rel="stylesheet" href="Assets/insert.css" type="text/css" />
</head>
<body> 
<div id="masthead"> 
  <img src="/Assets/title1.jpg" alt='' width="561" height="93" />
</div> 
<div id="content"> 
  <div id="breadCrumb"> 
  </div> 
 <!-- 	Begin contents inserted from blogs -->
<?php 
include('/home/cheever/public_html/Blogs/index_insert.php');   
?>
      <!-- 	End contents -->

12 Dec 09, 2006 15:13

balupton wrote:

Could you post the parts of the code say lines 1-10.

chennai wrote:

Here's 5-21:

:-/

13 Dec 09, 2006 16:37

Your output's already started before you get to this line of code :-

<?php
include('/home/cheever/public_html/Blogs/index_insert.php'); 

¥

*edit*
ack, to terse,

by the time you get to doing all this ( index_insert.php ) :-

<?php
require_once dirname(__FILE__).'/conf/_config.php';
require_once $inc_path.'_main.inc.php';
$blog = 1;      // All blog
$timestamp_max = 'now';
$posts= 5; // Show 5 posts
$skin="insert"; // Skin the insert
require $inc_path.'_blog_main.inc.php';
?>

You've already spat out all this :-

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cheever Family</title>
<link rel="stylesheet" href="Assets/common.css" type="text/css" />
<link rel="stylesheet" href="Assets/insert.css" type="text/css" />
</head>
<body>
<div id="masthead">
  <img src="/Assets/title1.jpg" alt='' width="561" height="93" />
</div>
<div id="content">
  <div id="breadCrumb">
  </div>
 <!--    Begin contents inserted from blogs -->
<?php
include('/home/cheever/public_html/Blogs/index_insert.php');   

14 Dec 10, 2006 00:34

Okay. I see the problem. How can I tell b2evo to give me the posts but not the cookie?

15 Dec 10, 2006 07:12

Your solution is to move all of this :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cheever Family</title>
<link rel="stylesheet" href="Assets/common.css" type="text/css" />
<link rel="stylesheet" href="Assets/insert.css" type="text/css" />
</head>
<body>
<div id="masthead">
  <img src="/Assets/title1.jpg" alt='' width="561" height="93" />
</div>
<div id="content">
  <div id="breadCrumb">
  </div>
 <!--    Begin contents inserted from blogs --> 

into the _main.php of your "insert" skin

¥

16 Dec 10, 2006 13:41

Thanks.

The trouble with that solution is that changing any content "above" the blog insert will require modifying the index_insert.php file. I don't think I can expect the folks using this (and by that I mean the other sites where I am doing something similar, e.g. eastultimate.org) to be able to do more than change the html. One of the nice things about the one line of php code dropped into the index.php page was that most of the page then looked like a regular page to those modifying it.

Hmm.

17 Dec 10, 2006 15:02

What happens if you include "no_skin.php" instead (it's in the root folder of your blog) where you have the line : include('/home/cheever/public_html/Blogs/index_insert.php');

You'd need to reduce the file to just the bit that displays the blog entries (ie, remove the <head> stuff etc) and in particular a line that looks like this : header( 'Content-type: text/html; charset='.$io_charset );

¥

18 Dec 11, 2006 23:04

Okay.

These lines at the very top of index.php:

<?php
require_once dirname(__FILE__).'/Blogs/conf/_config.php';
require_once $inc_path.'_main.inc.php';
?>

Then these (or a require to a file that contains these lines) where I want the posts:

  <?php 
$blog = 1;      // Your blog's number: see it in admin page
$timestamp_max = 'now'; //don't display future posts (you may have edited publication's date)
$posts= 10; //show 10 posts only
$skin="insert"; 
require $inc_path.'_blog_main.inc.php';
   ?>

Thanks very much for the help and suggestions!

19 Dec 14, 2006 17:35

I thought your index.php looked like this?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cheever Family</title>
<link rel="stylesheet" href="Assets/common.css" type="text/css" />
<link rel="stylesheet" href="Assets/insert.css" type="text/css" />
</head>
<body>
<div id="masthead">
  <img src="/Assets/title1.jpg" alt='' width="561" height="93" />
</div>
<div id="content">
  <div id="breadCrumb">
  </div>
 <!--    Begin contents inserted from blogs -->
<?php
include('/home/cheever/public_html/Blogs/index_insert.php');   
?>
      <!--    End contents -->


  <div class="story"></div>
</div>
<!--end content -->
<div id="navBar">

  <div class="relatedLinks">
    <h3>Down Under 2007</h3>
    <ul>
      <li><a href="../Blogs">Blog</a></li>
      <li><a href="#">Photos</a></li>
 
    </ul>
  </div>
 
</div>
<!--end navBar div -->
<div id="siteInfo">
  <a href="#">About Us</a> | <a href="#">Contact Us</a> | &copy;2006
  The Cheever Family
</div>
</body>
</html>

In which case you want to look at no_skin.php as being a replacement for your current

<?php
include('/home/cheever/public_html/Blogs/index_insert.php');   
?>

¥


Form is loading...