Another embedding question

Having trouble installing serendipity?
Post Reply
zerapio
Regular
Posts: 5
Joined: Tue Sep 21, 2004 4:21 am

Another embedding question

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Another embedding question

Post 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.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
zerapio
Regular
Posts: 5
Joined: Tue Sep 21, 2004 4:21 am

Post 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
marcderooij
Regular
Posts: 15
Joined: Mon Aug 09, 2004 9:48 pm
Contact:

embedding is not as easy as it seems

Post 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.
zerapio
Regular
Posts: 5
Joined: Tue Sep 21, 2004 4:21 am

Got it working

Post 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
TimmyT

Post by TimmyT »

thanks zerapio, that was just great... worked perfectly for me!
zerapio
Regular
Posts: 5
Joined: Tue Sep 21, 2004 4:21 am

:D

Post by zerapio »

Neat!! I'm happy that it helped somebody else. Did you modify the print entries as well?

-Z
Post Reply