Embedding in another page question

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
gc11
Posts: 4
Joined: Thu Dec 09, 2010 6:49 am

Embedding in another page question

Post by gc11 »

Hi there,

I've searched the forums about this problem and although i've found many people discussing it I can't seem to find a solution. Hopefully someone can help as it's driving me crazy, apologies if i've missed an answer or this is a really easy question!

Ok so, my company's blog is up and running, everything is working fine, i'm using the wrapper.php solution to embed my serendipity blog into my 'blog.php' file. I know i probably should be using the Smarty template way of doing things but initially i thought the wrapper way was easier. Anyway, as i said everything is working fine EXCEPT for broken links to 'www.mysite.com/blog.php.' I can get to the site from all my pages, i.e. the links actually works however , google and any link checker returns a 404. I believe the reason is that i have the following code in my blog.php above the header :

Code: Select all

<?php
require("wrapper.php");
?>
I've tried putting

Code: Select all

<!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">
above it but then i get the dreaded 'headers already sent' error.

My paths are as follows :

mysite.com/blog.php
mysite.com/wrapper.php
Index file for blog : mysite.com/serendipity/index.php

Code in wrapper :

Code: Select all

<?php
ob_start();
chdir("serendipity/");
require("index.php");
chdir("../");
$blog = ob_get_contents();
ob_end_clean();
?>
Code for echo of index :

Code: Select all

<?php
echo $blog;
?>
Any help would be greatly appreciated, and apologies again if this is something that has been brought up before.

Thanks.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Embedding in another page question

Post by garvinhicking »

Hi!

I guess the most easy way would be to simply insert a

Code: Select all

<?php
header('HTTP/1.0 200 OK');
?>
in your blog.php file. Also, make sure you're not having UTF-8 BOMs at the start of the file that would prevent emitting headers.

Other than that, can you provide your true URL? Then I could have a look at the HTTP headers specifically.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gc11
Posts: 4
Joined: Thu Dec 09, 2010 6:49 am

Re: Embedding in another page question

Post by gc11 »

Hi Garvin,

Thanks for your reply, i added the code to the top of my 'blog.php' in my root directory so now it looks like :

Code: Select all

<?php
header("HTTP/1.0 200 OK");
require("wrapper.php");
?>
The page is still working however the 404 errors are still there with google and any link checkers. I've also check my files for UTF-8 BOMs but can't seem to see any blanks at all. The URL is http://www.vismedchina.com/blog.php

Thanks again for your help.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Embedding in another page question

Post by garvinhicking »

Hi!

Depending on whether you use PHP as apache module or CGI, you might need this syntax:

Code: Select all

<?php
header('HTTP/1.0 200');
header('Status: 200 OK');
require("wrapper.php");
?>
instead?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gc11
Posts: 4
Joined: Thu Dec 09, 2010 6:49 am

Re: Embedding in another page question

Post by gc11 »

Hi Garvin,

Unfortunately i'd tried adding the CGI already, just tried it again now but still no luck. Just don't understand it.

Thanks again.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Embedding in another page question

Post by garvinhicking »

Hi!

Hm, it might be that due to your "blog.php" not living inside the same directory like the "indexFile" that s9y does not recognize your normal URL as a valid URL, and thus displays the default 404 view (your blog) and emits a 404 header.

To circumvent that, the easiest way would be to patch your s9y's index.php and simply comment out all header('StatuS: 404 not found') calls in the code (there are multiple occurences, the one that counts in your case is the last one).

The harder way would be to make sure that indexFile points to a wrapper inside your serendipity subdirectory, and make calls to the blog always go to the main blog directory as well, or using URL rewriting. But I haven't done this in ages, so probably the patch would be the less intrusive option. ;)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gc11
Posts: 4
Joined: Thu Dec 09, 2010 6:49 am

Re: Embedding in another page question

Post by gc11 »

Hi Garvin,

I tried the patch and you've done it! No more 404's, I have a couple coming up further down the line but I think i can deal with them so for now I am happy!

Really appreciate your help, thanks very much again.
Post Reply