Page 1 of 1

Another embedding question

Posted: Tue Sep 21, 2004 5:53 am
by zerapio
Hello all, I installed this wonderful blog and then though about using it to display log entries on my main site. I also want to have the full, regular blog in a subdirectory to access the search function, to log in, etc.

I thought that the embedding option was what I needed but the problem is that when I use it I lose the general blog. I only see the posts.

I've read almost all the other threads on the topic and didn't find a solution to this. So here is my question a bit more clearly.

How do I initialize the blog and retrieve the n most recent entries to display them? The main page is located in a directory different to the blog.

Thanks,
-Z

Re: Another embedding question

Posted: Tue Sep 21, 2004 10:53 am
by garvinhicking
Hi!

You should fetch your own RSS feed and display the entries from there, that's the easiest way.

If you want to do it the hard way, you need to include the s9y infrastructure from your mainpage (include serendipity_config.inc.php and others - see the index.php for a list which files you need). Then you need to call serendipity_fetchEntries() and after that you can format the entries the way you like (thus bypassing serendipity_printEntries()).

An alternative "hard way" is to use the embed mode and edit the layout.php file so that when you are viewing the blog NOT from your main directory, it will emit the HTML headers from serendipity_genpage.inc.php. (copy+paste)

HTH,
Garvin.

Posted: Tue Sep 21, 2004 11:14 am
by zerapio
Thank you very much for your suggestion. I was hacking the code and got it half working but it's a bit complicated when one doesn't know the whole structure. The RSS idea sounds interesting but I don't know much about RSS. I'll try the modified layout solution and come back with my results.

-Z

embedding is not as easy as it seems

Posted: Mon Sep 27, 2004 11:13 pm
by marcderooij
Hi,

I think I had kind of the same problems as you did. I wanted to embed my weblog in the rest of a site, but found that when I used the 'embed' directive, too much disappeared.

The weekend, I eventually hacked the layout.php to my desires, and it has worked out quite nice. This keeps the normal sidebar functions, and lets you meddle with a blog in a full site.

See http://sandcat.nl/~marc if you want to see what I mean. It's still empty however, and in Dutch. But you'll gey my point.

Got it working

Posted: Mon Oct 11, 2004 5:31 am
by zerapio
garvinhicking, thanks for your suggestion. The hard way ended up being easier than I thought. I included the header, got the entries to a string and printed them using printEntries. One problem I had was that printEntries prints a footer with a link to the next page of entries. This doen't work when I embed s9y this way. Since I really don't need it working, I just created a My_serendipity_printEntries() where I commented out the call to printEntryFooter.

Here's the code in case someone needs it in the future:

Code: Select all

<?php

chdir('../blog'); // Change current directory to s9y

// Include header
include_once('serendipity_config.inc.php');

// This is optional
$description = $serendipity['blogDescription'];
$title = $serendipity['blogTitle'];
$comments = FALSE;

// Get the 5 most recent entries
$entries = serendipity_fetchEntries(null, true, 5);

// Print them
My_serendipity_printEntries($entries);
?>
Again, My_serendipity_printEntries is the same as the original (a copy) with serendipity_printEntryFooter() comented out (twice near the end).

Cheers all
-Z

Posted: Thu Oct 21, 2004 9:37 am
by TimmyT
thanks zerapio, that was just great... worked perfectly for me!

:D

Posted: Thu Oct 21, 2004 9:40 am
by zerapio
Neat!! I'm happy that it helped somebody else. Did you modify the print entries as well?

-Z