newbie question: The 'embed' Configuration Directive ?!

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
smartin
Regular
Posts: 17
Joined: Tue Oct 17, 2006 4:31 pm

newbie question: The 'embed' Configuration Directive ?!

Post by smartin »

Hi,

Completely new here. Just easilly installed s9y. Looks promissing!

I have read The 'embed' Configuration Directive (http://www.s9y.org/55.html#A2) but I completely do not understand it. Neither of the methods. I do have some knowledge of php but it doesn't help me here.

Method 1: I need to create a file called content.php and wrapper.php, upload them and change a settting. I tried it but no magic.

Method 2: I need to edit a template file (add html like a header and footer). But the only template files I can find are folders containing stylesheets and images and no html pages. Completely lost there too.

Can anyone give me a hand?
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Well, I'll try. Embedding is probably the hardest operation to achieve with any software, so you're in for a wild ride if you really want to do this.

First off, that "embedded" option. It basically makes Serendipity output everything between the <body> tags, but nothing else (and no <body> tags, either). That's it. So if you're embedding Serendipity, something else has to take care of the headers and body. That's the "content.php" we're talking about. I'll also call it the "embedding application".

Normally that's an existing web page or web application. Like "gallery.php" or "my_custom_website.php". You can even put it in "index.html" if you know what you're doing on the server. But Serendipity is fully capable of creating entire webpages on its own, so you only need to embed if you really want to put Serendipity inside an existing page or application.

If you've read this far, you probably want to embed. So be it.

Since you know PHP, you'll recognize the ob_start(), ob_get_contents() and ob_end_clean() methods. If you call Serendipity with these methods, all the output will go to a variable instead of to the web page. Then you print the variable inside your content.php. Ta-da! Serendipity Embedded.

There are only two hitches: first, Serendipity needs to be called from its own directory, before anything else outputs HTTP headers. That's what the "wrapper.php" is for. Second, Serendipity's links will point to the blog itself. For that, you change the IndexFile option to point at content.php. Serendipity's links will then point at your embedding application instead of at itself. Of course, the embedding application had better pass on all the variables and GET/POST stuff. If not, you can always modify your wrapper.php to call first Serendipity and then your original application.

You can find more detail on embedding at http://www.s9y.org/123.html, with an example wrapper.

The second method you mentioned actually does a sort of reverse embedding. With that, you move all the embedding application's stuff inside the index.tpl. That's the start point for all of Serendipity's processing. If you inserted stuff at the top and bottom, with the "embed" option on, that stuff would become the new <head> and <body> for Serendipity. So you're kinda embedding the content.php in Serendipity, instead of the other way around.

As you've noticed, though, some templates don't have an index.tpl. That's because Serendipity uses a "fallback" method of finding files. If it's not in the current template, Serendipity looks in the default/ template directory. So you can make a new "template" by just creating a new directory and creating an info.txt file with a new name. (Wouldn't do anything, but...) Then you could copy only the files you want to change and make the mods you want.

Whew. I'm long-winded, but I hope I answered your questions. If anything was unclear, or if I missed something, please feel free to ask.
Judebert
---
Website | Wishlist | PayPal
smartin
Regular
Posts: 17
Joined: Tue Oct 17, 2006 4:31 pm

Post by smartin »

Well this is much clearer than the docs I read so far. Thanks a lot Judebert. It's a great help! If I have any more questions I'll get back to you.
Post Reply