Page 1 of 1

Yet another embedding question

Posted: Wed Dec 29, 2004 7:13 am
by notset4life
I have tried to make sense out of the embedding thing, but can't seem to figure the wrapper stuff out since I don't call my web page the way the instructions say. I want to add serendipity to my main site, not vice-versa.

Right now the way I've configured it, I have a default.php which includes
nothing but an includes to my blog, and in my blog template, I've included a my header and my footer. It all works well, I just think there must be a better way to do this, and there are a few problems when I try to use includes for certain news items, the my site template gets repeated within the blog. Therefore I would rather not place my header and footer in the template file

Can someone point me towards a way to embed Serendipity using a normal web site layout (and again, not as in the instructions.
(hope this makes sense)

TIA

Re: Yet another embedding question

Posted: Wed Dec 29, 2004 4:00 pm
by garvinhicking
Hm, since I wrote the instructions, I may be the wrong one to respond.

Nevertheless, if you don't want to include your header and footer in default.php, you obviously need to include serendipity output in your homepage template.

You need to use ob_start() and ob_get_contents() as described in the instructions to capture all Serendipity output and then make it fit in your template. The basic idea of turning on the "embed" option of s9y Configuration is that then s9y doesn't emit HTML header and footer files, so that you can do that yourself in your own template.

Regards,
Garvin

Posted: Wed Dec 29, 2004 4:51 pm
by Guest
Garvin, thanks for taking the time to respond. I tried obstart and I had the same problem someone else had...it said serendipity isn't installed.
I don't quite know how to use the chdir command.

Posted: Wed Dec 29, 2004 5:37 pm
by notset4life
Actually, I figured some of it out...but here is where the problem still lies.

My headers and footers are in my root in a file called default.php

Serendipity is installed in a folder called /news

I placed this code in default.php

Code: Select all

<?php 
ob_start(); 

chdir('/www/mysite.com/htdocs/news');
require '/www/mysite/htdocs/news/index.php'; 
$blog_data = ob_get_contents(); 
ob_end_clean(); 

echo $blog_data; 
chdir('/www/mysite.com/htdocs');
?> 
All looks fine, except when a new story is clicked, it opens up without the headers and footers. I seem to be in a catch 22.

Posted: Wed Dec 29, 2004 7:59 pm
by garvinhicking
Yeah - you're on the right track. And you're hitting the problem why $serendipity['indexFile'] was invented. :)

Set that to your "default.php" file. Create a default.php file in your /news directory. Let that contain:

Code: Select all

<?php
chdir('..');
require 'default.php';
?>
and then you should be settled. Eventually you'll need to set the URL Rewriting option to "none" and then back to "Apache Errorhandling" so that Serendipity updates your .htaccess file...

Does that help you further? I hope so, if not, just report back :)

Regards,
Garvin

Posted: Wed Dec 29, 2004 9:04 pm
by notset4life
Garvin,
Beginning the see the light, but it still doesn't work. I am getting the 2 default.phps confused. Please tell me if this is right:


1. In configuration, under paths, set index file just to "default.php"?
Is this the default.php I create in /news directory?


2. Create default.php in NEWS directory
<?php
chdir('..');
require 'default.php';
?>
This should point to the ROOT directory...so chdir should read the path
to my root?

Thanks again, and sorry if I sound a little confused.

Posted: Wed Dec 29, 2004 11:19 pm
by notset4life
Got IT! I had to to that rewritting thing with htaccess, and it works perfectly.

Thanks again for your time and your help. Happy new year.

SPAM PROTECTOR CAPTCHA NOT WORKING

Posted: Thu Dec 30, 2004 12:49 am
by notset4life
After getting all the embedding stuff figured out, I noticed that CAPCHA does not work, it just shows a missing image. I look at the source code and I see:

<img src="http://www.website.com/news/plugin/capt ... 64f9eaf4a6"

I believe it should read news/pluginS (plural)

How can I fix this?

thanks again
v

Re: SPAM PROTECTOR CAPTCHA NOT WORKING

Posted: Thu Dec 30, 2004 11:00 am
by garvinhicking
Great that you got it basically working :)

The thing with "plugin" is that it uses rewriting mechanism just like "archives/x-bla.html" stuff. Your default.php needs to be configured so that the header and footer is not shown when the URI /plugin/ is used:

Code: Select all

/default.php
<?php
ob_start();

chdir('/www/mysite.com/htdocs/news');
require '/www/mysite/htdocs/news/index.php';
$blog_data = ob_get_contents();
ob_end_clean();

echo $blog_data;
chdir('/www/mysite.com/htdocs'); 
if (preg_match('@/plugin/@', $_SERVER['REQUEST_URI'])) {
  exit;
}

?>
A few months ago I used the same embedding method and got it working with an easier way...but I can't remember which :-D

Regards,
Garvin