Page 1 of 1

Embedding Again

Posted: Wed Aug 02, 2006 7:42 pm
by elliot
I don't suppose i'll be the last to have a problem with this.

I would like to run through what I have done as it seems to differ from some but have similar problems as others. I am not getting errors which is a start but I am not seeing the blog printed.

It may be to do with directory stucture because the the file I am trying to embed to is in a different folder to the serendipity folder and not even on the level above.

Ok, I am trying to embed to a file called news.php in the <root>/site folder

I news.php I have:

<?php
require("http://<completeURL>/site/wrapper.php");
?>

at the top and

<?php
echo $serendipity_contents;
?>

where I want it to be

the wrapper file has the following:

<?php
ob_start();
chdir("http://<completeURL>/serendipity/");
require("index.php");
chdir("http://<completeURL/site/");
$serendipity_contents = ob_get_contents();
ob_end_clean();
?>


When I change the indexfile to wrapper it seems to screw up the admin section so I don't know what going on.

any suggestions appriciated.

Elliot

Posted: Wed Aug 02, 2006 8:46 pm
by judebert
A good start.

The (first) problem is that the chdir() function doesn't use a URL, it uses a directory. I assume your *directory* structure looks something like:

Code: Select all

<whatever root directory, probably htdocs>
  serendipity/
    serendipity_subdirs/
  site/
    site_subdirs/
In this case, your news.php is executing in site/, and it needs to reference stuff in ../serendipity.

I'd delete my wrapper.php, set the indexfile back, and try this in my news.php:

Code: Select all

<?php
ob_start();
chdir("../serendipity");
require("index.php");
chdir("../site");
$serendipity_contents = ob_get_contents();
ob_end_clean();
?> 
I think that should do it. Let me know!

Posted: Wed Aug 02, 2006 10:19 pm
by elliot
Hi thanks for the advice but I am getting an error with that idea:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/catalog/news.php:1) in /var/www/html/catalog/includes/functions/sessions.php on line 97
It is a php page which is why I was doing the wrapper route of things.

I was actually getting the blog showing when I did a simple php include on the index.php page just that the links to comments opened on a new window so I thought there must be another way.

I tryed the wrapper but i'm getting a blank page. I modified the absolute links as I had them before to ../directory links but still blank.

thanks again

Posted: Wed Aug 02, 2006 10:50 pm
by elliot
okay, just been fiddling and put ../ in the wrapper file as well and it showed up i.e.
<?php
ob_start();
chdir("../serendipity");
require("index.php");
chdir("../site");
$serendipity_contents = ob_get_contents();
ob_end_clean();
?>
and the page shows but then comes up with this error next time it refreshes.
Fatal error: Unknown(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition <b>navigationhistory</b> of the object you are trying to operate on was loaded _before_ the session was started in /var/www/html/site/includes/application_top.php on line 30
I still have the indexfile set as index.php and have tried ../site/wrapper.php and putting the wrapper.php in the serendipity file but still the error.

any thoughts?

Posted: Thu Aug 03, 2006 4:34 pm
by judebert
What's at site/includes/application_top.php at line 30? It looks like it's trying to use $something->navigation_history, and that's returning an error.

Is application_top.php another wrapper? It's not usually part of Serendipity.

The "headers already sent" error happens because Serendipity must be called first. It looks like your main-site application does some other work before calling news.php; in that case, I'd recommend finding the main site's index.php, calling the Serendipity wrapper at the beginning there, and just using the $serendipity_content variable inside news.php.

I'm also a little confused over how your files stand now. I'm assuming news.php has only the require statement and wrapper.php has the wrapper code you referenced.

So, for clarification: we're now talking about using a wrapper.php with the code above to call Serendipity. We need to require the wrapper.php first thing, at the top of the index.php or its equivalent. Then we can use the $serendipity_content in the news.php. (Phew!)

I think that covers it. Let me know!