[SOLVED] Embedded Breadcrumb Navigation

ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Mon, 2005-04-18 04:29

Hiya,

Having a problem with using the breadcrumbs for navigation when running a embedded gallery.

As soon as you navigate down into sub albums and select the breadcrumb you get the following error message..

Warning: Cannot modify header information - headers already sent by
(output started at /gallery2.php:11) in gallery2/main.php on line 416

You can reproduce the issue by navigating via the following link -> http://www.ozgreg.com/gallery2.php

 
arnoadam

Joined: 2004-09-29
Posts: 32
Posted: Mon, 2005-04-18 09:12

I'm also trying to integrate Gallery2 with my Wordpress install and having the same problem, dunno what it is...

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Mon, 2005-04-18 10:27
 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-04-18 11:30

what is in your main.php on line 416?

 
arnoadam

Joined: 2004-09-29
Posts: 32
Posted: Mon, 2005-04-18 11:40

header("Location: $redirectUrl");

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-04-18 12:05

most often the reason for these "headers are already sent" errors is that there is a space/newline at the end of one of the involved files or that there's somewhere some debug output.
the first place i'd start searching is config.php (but then all G2 pages should show the error) and then the files you edited.

 
arnoadam

Joined: 2004-09-29
Posts: 32
Posted: Mon, 2005-04-18 12:09

The strange thing is that I don't get this error if I browse the gallery as stand alone... (www.mysite.com/galley2/main.php)

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Mon, 2005-04-18 13:42

It is an embedded problem not a stand alone problem, take away the embedding and it works fine..

I am also getting the same error message when performing Editing on Albums etc..

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2005-04-18 14:30

that means the extra space or blank line is in your embed code or the embedding app, and not in any G2 file. the "headers already sent" message will tell you "output started at..." so you can find the extra whitespace to remove.

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Mon, 2005-04-18 14:45

Mindless, Firstly I believe you would be getting this error all the time if it is a space issue in the calling embedding code secondly the error seems to be just limited to when gallery redraws a screen it has already rendered. (IE When navigating via the breadcrumbs and also when selecting an action (ie rebuilding thumbnails) in the Album Edit.)

I thought it was some template problem until I could also get the error during Album Editing..

 
arnoadam

Joined: 2004-09-29
Posts: 32
Posted: Mon, 2005-04-18 17:40

any Ideas where to start looking for the source of this error?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-04-18 17:44
Quote:
Warning: Cannot modify header information - headers already sent by (output started at /home/.bain/ozgreg/ozgreg.com/gallery2.php:11) in /home/.bain/ozgreg/ozgreg.com/gallery2/main.php on line 416

-> the error is in your gallery2.php file at line 11. look for newlines, spaces, ...

 
arnoadam

Joined: 2004-09-29
Posts: 32
Posted: Mon, 2005-04-18 18:06
Quote:
Cannot modify header information - headers already sent by (output started at /home/arno/public_html/foto.php:7) in ...."

Line 6-8 in foto.php
6: <head profile="http://gmpg.org/xfn/11">
7: <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
8: <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" />

If I try to remove line 7 I get the same error again. It looks like the error always are in the first line in the <head> section.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2005-04-18 18:37

arnoadam, you need to rework your embedding code.. you can't output any html before calling GalleryEmbed::handleRequest.

 
arnoadam

Joined: 2004-09-29
Posts: 32
Posted: Mon, 2005-04-18 19:12

Thnx!
That's it, everyting are working now!

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2005-04-18 22:43

arnoadam, great!
ozgreg, were you able to fix up your gallery2.php file?

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Mon, 2005-04-18 23:41

No I moved around the $g2data = GalleryEmbed::handleRequest(); before any HTML output which was the issue however when you select a breadcrumb now you just get a blank page..

<?php
  require('./wp-blog-header.php');
  require_once(dirname(__FILE__) . '/gallery2/embed.php');

// Get the WP User ID -> Blank if Not Logged in
  
  get_currentuserinfo();  // Get the Current WP User

  $ret = GalleryEmbed::init(array(
           'embedUri' => 'gallery2.php', 'relativeG2Path' => 'gallery2', '$loginRedirect' => 'gallery2', 'activeUserId' => $user_ID));
  if ($ret->isError()) {
    $ret = GalleryEmbed::init(array(
           'embedUri' => 'gallery2.php', 'relativeG2Path' => 'gallery2', '$loginRedirect' => 'gallery2', 'activeUserId' => ''));
	   if ($ret->isError()) {
	    print $ret->getAsHtml(); //has error details..
		 exit;
		}
  }

  $g2data = GalleryEmbed::handleRequest();

  ?>

  <!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 profile="http://gmpg.org/xfn/1">
	<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" />
	<title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
	<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats please -->
	<style type="text/css" media="screen">
		@import url( <?php bloginfo('stylesheet_url'); ?> );
	</style>
	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
	<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
	<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />

	<?php wp_get_archives('type=monthly&format=link'); ?>
	<?php comments_popup_script(); // off by default ?>
	<?php wp_head(); ?>
   </head>
   <body>
   <div id="rap" style="background-image: none">
   <?php get_header(); ?>
	<div id="content">
		<div id="topbar">
		<ul class="navbar">
				<a href="/" title="Home Page">home</a>	|
				<a href="http://www.ozgreg.com/gallery2.php" title="Gallery">gallery</a> | 
				<a href="http://www.ozgreg.com/archives.php" title="Archives">archive</a> | 		
		</ul>
		  </div>
</div>
<?php

  print $g2data['bodyHtml'];
  get_footer(); 
?>
 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-04-19 05:52

ah, i see the problem. you don't obey the 'isDone' tag.
if G2 already redirects/outputs something directly, i.e. doesn't use the parents template, then it sets the $g2data['idone'] (see embed.php for spelling, not sure right now).
so if (isset($g2data['idone']) && $g2data['idone']) {
exit;
}
and don't output any html for yourself.

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Tue, 2005-04-19 08:27
valiant wrote:
ah, i see the problem. you don't obey the 'isDone' tag.
if G2 already redirects/outputs something directly, i.e. doesn't use the parents template, then it sets the $g2data['idone'] (see embed.php for spelling, not sure right now).
so if (isset($g2data['idone']) && $g2data['idone']) {
exit;
}
and don't output any html for yourself.

I removed that code because it was outputting a BLANK page when this happened because of the exit command..

I originally had..

  $g2data = GalleryEmbed::handleRequest();
  if ($g2data['isDone']) {
    exit; // G2 has already sent output (redirect or binary data)

Which = Blank page when reusing any page (ie breadcrumb)

 
arnoadam

Joined: 2004-09-29
Posts: 32
Posted: Tue, 2005-04-19 08:55

this is my foto.php and it's working for me.....

<?php 
require('./wordpress/wp-blog-header.php');
require_once($_SERVER["DOCUMENT_ROOT"].'/gallery2/embed.php');

get_currentuserinfo();  // Get the Current WP User

  $ret = GalleryEmbed::init(array(
           'embedUri' => 'foto.php', 'relativeG2Path' => 'gallery2', '$loginRedirect' => 'foto.php', 'activeUserId' => $user_ID));
  if ($ret->isError()) {
    $ret = GalleryEmbed::init(array(
           'embedUri' => 'foto.php', 'relativeG2Path' => 'gallery2', '$loginRedirect' => 'foto.php', 'activeUserId' => ''));
      if ($ret->isError()) {
       print $ret->getAsHtml(); //has error details..
       exit;
      }
  }

  $g2data = GalleryEmbed::handleRequest();
  if ($g2data['isDone']) {
    exit; // G2 has already sent output (redirect or binary data)
  } 

?> 
 <!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 profile="http://gmpg.org/xfn/11">
  <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
  <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" />
  <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats please -->
  <script src="<?php bloginfo('template_directory'); ?>/js_quicktags-mini.js" type="text/javascript"></script>
  <style type="text/css" media="screen">
   @import url( <?php bloginfo('stylesheet_url'); ?> );
  </style>
  <link rel="stylesheet" type="text/css" href="http://www.mysite.com/gallery2/layouts/siriux/layout.css"/>
  <link rel="stylesheet" type="text/css" href="http://www.mysite.com/gallery2/templates/layout.css"/>
  <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
  <link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
  <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
  <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
  <?php wp_get_archives('type=monthly&format=link'); ?>
  <?php //comments_popup_script(); // off by default ?>
  <?php wp_head(); ?>
 </head>

 <body>
  <a name = "top"></a>
  <div id="hnav">
   <div id="hmenu">	
    <ul id="top"> 
     <li><a href="#bottom" title="search in previous posts">search</a></li>
     <li><?php wp_loginout(); ?></li>
    </ul>
   </div>
   
   <div id="header">
    <h1 id="blogtitle">
     <a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?>
     </a>
    </h1>
   </div>
  </div> <!-- Closes the hnav div-->
 <div id="masthead" onclick="location.href='<?php bloginfo('url'); ?>';" style="cursor: pointer;">
</div>
 <div id="container">
  <div id="topcontent"></div>
  <div id="singlecontent">

<?php
  print $g2data['bodyHtml'];
?> 

</div>
   <div id="bottomcontent"></div>
  </div>
 </div>

<?php get_footer(); ?>
 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Tue, 2005-04-19 10:10

Which is what I have got which leads to a blank page when I use the breadcrumbs..

Just as a side not you do not need

<link rel="stylesheet" type="text/css" href="http://www.mysite.com/gallery2/layouts/siriux/layout.css"/>
<link rel="stylesheet" type="text/css" href="http://www.mysite.com/gallery2/templates/layout.css"/>

If you add the elements of those stylesheets to your WP Style. In fact I would recommend doing this so you can easy do a one style sheet changes everything approach..

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-04-19 10:43

ozgreg, without taking a closer look (cause i fail to understand why this happens),... please take a look at the xaraya integration file xaruser/main.php (this corresponds to this gallery2.php file.
'cause the xaraya integration works, also for breadcrumb links.
see the demo at http://nei.ch/test/xaraya/ (out of date, demo install only)

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Tue, 2005-04-19 11:07

Believe me Valiant I have pulled the php apart and back together, moving from simple to complex scripts. I been adding php apps to phpbb boards for a few years so I am not a stranger to the template environments but this one has gotten me by the short and curly..

Frustrating as all hell, because I got my site css working well except for this..

*sighs*

Edit: Now this is interesting I turned off require('./wp-blog-header.php');
and the breadcrumbs worked fine.. (Gallery was in embedded standalone) ;)

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Tue, 2005-04-19 22:32

Unfortunately It just been proved that nothing is wrong with my embedding code for WP and G2. It seems on certain hosts WP & G2 do not play well together.

I cannot see anyway forward on this other than to abandon this integration and looking for alternativeness that do play well.

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Tue, 2005-04-19 22:40

ozgreg, can you elaborate on how/why that happens?

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Wed, 2005-04-20 07:51
h0bbel wrote:
ozgreg, can you elaborate on how/why that happens?

The issue is for some unkown reason in my hosting environment as soon as I run embedded Gallery selecting a WP breadcrumb the page just fails to load (they return blank) (even although the URL is correct)

Valiant has kindly verified my embedded script, and loaded a blank copy of WP / Gallery on his servers verifying I was not losing my mind..

I also did the same with another vanilla installation of WP/Gallery verifying that I was losing my mind..

In all cases I cannot get my breadcrumbs to work while using the same script Valiant G2/WP breadcrumbs work fine..

You are very welcome to look @ my site right now and see the issue first hand -> http://ozgreg.com/

Short of moving hosting firms I am just about out of options..

 
arnoadam

Joined: 2004-09-29
Posts: 32
Posted: Wed, 2005-04-20 09:35

ozgreg, I don't think there is anything wrong with your code but did you try arnoldjw's plugin?

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Wed, 2005-04-20 10:06
arnoadam wrote:
ozgreg, I don't think there is anything wrong with your code but did you try arnoldjw's plugin?

This one -> http://wordpress.org/support/topic.php?id=31329

Then the answer is yes. I like his work although he has a few stylesheet issues, and I would like to change some of the way his code works because G2/WP allows better detection that just reading cookies etc.

Same issue however :( As soon as I navigate via a breadcrumb = blank page..

 
onlydarksets

Joined: 2005-04-19
Posts: 2
Posted: Wed, 2005-04-20 10:18

UPDATE: Nevermind! I missed the "get_header()" call at the top. Taking that out fixed my problem.

I am having a similar problem on my site (http://blog.mahshie.net/photos.php), although I get the following error message:

Warning: Cannot modify header information - headers already sent by (output started at /home2/mahshie/public_html/blog/wp-content/themes/borderlinechaos/header.php:6) in /home2/mahshie/public_html/blog/photos/main.php on line 416

My embed file (photos.php) file is based on ozgreg's code, but is pretty simple:

<?php
  require('./wp-blog-header.php');
  get_header();
  require_once(dirname(__FILE__) . '/photos/embed.php');
  $ret = GalleryEmbed::init(array(
           'embedUri' => 'photos.php', 'relativeG2Path' => 'photos', '$loginRedirect' => 'photos', 'activeUserId' => ''));
  if ($ret->isError()) {
    // $ret->getAsHtml() has error details..
    exit;
  }

  $g2data = GalleryEmbed::handleRequest();
  if ($g2data['isDone']) {
    exit; // G2 has already sent output (redirect or binary data)
  }
?>

<div id="rap">
<div id="container" class="clearfix">
<div id="contentwrapper">
<div id="content">
<div id="maincol"><!-- The main content column begins  -->
<div class="col"><div class="entry">


<?php
  print $g2data['headHtml'];
  print $g2data['bodyHtml'];
?>

</div>
</div>
</div>
</div>
</div>
</div>

<?php
  get_footer();
?>

Am I having the same problem, or am I missing something obvious?

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Fri, 2005-04-22 10:52

I been playing around and playing around getting my hosting company to do some serious work on why my Gallery was returning a blank page then I noticed that G2 on the breadcrumbs changes the URI and basically adds a highlightid..

arg3="highlightId=`$layout.parents[parent.index_next].id`

It is this that is breaking my Gallery! When I removed the highlight from my URI (pathbar.tpl) all was smooth sailing..

What does highlightId do in the URI and am I breaking Gallery in removing it??

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2005-04-22 13:46

including the highlightId parameter will make it jump to the right page of a multipage album.. ie, if you're viewing photo X and click it's parent album Y in the breadcrumb it will go to page 3 of Y if that's where X's thumbnail is shown.. (it sends a redirect to reach this page, don't know if that's any help it why it doesn't work for you).

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Sun, 2005-04-24 12:30

Update Thanks to Bharat help, we added the following code to my gallery2.php which has fully restored the breadcrumbs..

  // In PHP/CGI mode, this gets set to /gallery2.php, but that can confuse
  // WP who expects that to be a rewrite rule of some kind.  So since we know
  // that we're not using PathInfo, just unset this here before we load
  // wp-blog-header.php
  unset($_SERVER['PATH_INFO']);
 
therapiekind
therapiekind's picture

Joined: 2007-04-19
Posts: 3
Posted: Thu, 2007-04-19 15:30
ozgreg wrote:
Update Thanks to Bharat help, we added the following code to my gallery2.php which has fully restored the breadcrumbs..

  // In PHP/CGI mode, this gets set to /gallery2.php, but that can confuse
  // WP who expects that to be a rewrite rule of some kind.  So since we know
  // that we're not using PathInfo, just unset this here before we load
  // wp-blog-header.php
  unset($_SERVER['PATH_INFO']);

Where exactly did you put this? I'm experiencing the same problems on a typo3 systems with embedded gallery2.