I wanted to maintain the formatting of the overall page, so insisted on going the embed-Serendipity-in-a-page route. Honestly, the documentation while accurate is extremely hard to puzzle out. Even for this programmer. I did finally get it working however. So, here is what I learned.
In the page you are going to embed the blog in (call it blog.php), you must start the page with the famous require block:
Code: Select all
<?php
ob_start();
chdir("<serendipity_dir>/");
require("index.php");
chdir("<original_dir>/");
$blog = ob_get_contents();
ob_end_clean();
?>
Next, in the main body of the page, wherever you want the blog to appear:
Code: Select all
<?php
echo $blog;
?>
Now, in the admin control panel, you must go to the Configuration>Paths page and set your index file name to the page the blog is embedded in.
So as an example, I have Serendipity loaded in a subdirectory called "blog", the include block looks like this:
Code: Select all
<?php
ob_start();
chdir("blog/");
require("index.php");
chdir("../");
$blog = ob_get_contents();
ob_end_clean();
?>
I also experimented with the separate wrapper method. The only changes are the wrapper file (wrapper.php) consists entirely of the beginning require block above. In blog. php the beginning block is simply
Code: Select all
<?php
require("wrapper.php");
?>
I stuck with the first method as there is one fewer files for manage. Simpler is better.
So to sum up:
- Insert the main php block reading the Serendipity index page at the very beginning of your file.
- Insert the echo statement block where you want the blog to appear within the page.
- No indentation for RSS/ATOM to work.
- Set the control panel Configuratio>Paths>index file to the file name that you are embedding in.