Embedding the hard way...

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
dyalekt
Posts: 4
Joined: Thu Nov 13, 2008 5:48 pm

Embedding the hard way...

Post by dyalekt »

So I've looked all over the forum and through all the documentation and still see nothing about it. I figured this would have been asked a long time ago but no one seems to ask what I'm asking in any of the posts I've seen. I am moderate at PHP so I dont need complete newbie language (lol) but this is my question:

I want to embed serendipity into my website the hard way specifically because my content requires it, but I need to figure it out. I used to use CuteNews to do any type of blogging to news posting on my websites but the problem is since it doesnt work w/ MySQL tables its very easy to spam in comments and such, plus obviously does not have the same benefits of this blog script. I looked all around the net and chose this script because it was the only one that SPECIFICALLY stated in its features that you can embed it rather than building around it.

Now to my question (as I feel may be a very simple idea without the answer I want), I want to know how to embed different pieces of the blog (the blog itself, comments, latest comments, latest posts, archive, etc) in different places. If that doesnt make sense, right now as far as embedding I see:

Code: Select all

<?php
echo $serendipity_contents; // Print the variable
?>
(obviously after the ob code)

All I want to do is have seperate prints for each piece

Code: Select all

<?php
echo $serendipity_latestcomments; // Print the variable
?>
(show latest comments)

Code: Select all

<?php
echo $serendipity_latestposts; // Print the variable
?>
(show latest blog posts)

Code: Select all

<?php
echo $serendipity_blog; // Print the variable
?>
(the article itself)

Code: Select all

<?php
echo $serendipity_shoutbox; // Print the variable
?>
(the shoutbox)

and so on... Now I am NOT asking that the codes look or labeled specifically like this ('$serendipity_blog', etc), I only used these codes for the example of what I'm doing... Now though CuteNews had a lot less features and is simply news rather than an official blog, it was easily able to do these things and its imperative that I have them.

Heres an example of the layout:

http://www.***************

Thats my basic layout / I threw in the "latest posts" and "latest comments" and a sample shoutbox just for the sake of design and seeing it as I build it.

Unfortunately if serendipity cant do what I'm asking I think I'm going to have to find something else...

If someone can help me that'd be fantastic. ;)
Last edited by dyalekt on Thu Dec 11, 2008 9:12 pm, edited 1 time in total.
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

It can be done, but it's a real pain in the rear. Garvin can tell you specifically what calls will retrieve what pieces; he generally answers questions here about twice a day.

I don't think it's broken down to the individual plugins, like the shoutbox. On the other hand, after index.php is done executing, practically everything is contained in the $serendipity variable; you might be able to var_dump it to see where your desired pieces are kept. And on the third hand, you could call anything if you just duplicate the index.php functionality in your own script (although that's a big pain in the rear, too).

Most people only want the entries; they use the Show Entries via JavaScript plugin. You seem to want more.

I started off a lot like you; I wanted Serendipity to just provide the pieces in my regular website. Over time, I came to realize that Serendipity could actually run the whole thing much more easily. You can call custom PHP if you have to, and templating is very simple with Smarty. And from within Smarty, the blog pieces are much more easily accessed.
Judebert
---
Website | Wishlist | PayPal
dyalekt
Posts: 4
Joined: Thu Nov 13, 2008 5:48 pm

Post by dyalekt »

I figured, but as long as it can be done. I'm already considering buidling the layout around s9y but I'm nervous to lose some of my simpler necessities. I guess it would be best to do it now since the site isn't established yet but I would still rather integrate it into my layout if possible, even if its a pain, as long as I can have it done in a weeks worth of time. I week for me being worked around about an hour each day to fit around my work schedule. I just want to be able to take advantage of all of the benefits aswell.

So I guess I'll wait to see if Garvin can answer it for me ;)

Thanks for tha input. Much appreciated.
dyalekt
Posts: 4
Joined: Thu Nov 13, 2008 5:48 pm

Post by dyalekt »

And on another note I'd even be willing to pull the information I'm looking for directly from the MySQL tables (atleast on the ones that its actually possible).
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Okay.

Actually, what you want is not really called embedding. What we call embedding is a way of your website having its own footer and header and sidebar location, but all the core content comes from Serendipity, without you interfering or mangling with it.

What you want is more to use the Serendipity API commands to execute certain tasks.

The good news: This can be done. Actually, Serendipity is developed to be a framework, not a distinct application. So internally, Serendipity simply requires core files and defines a subset of API commands based on the current page code. There are functions like serendipity_FetchEntries(), serendipity_printEntries(), serendipity_fetchComments(), serendipity_printComments() which you can subsequently call.

The bad news: it involves a lot of pain to learn the serendipity API so that you can fully use its potential, and put the different PHP functions together.

Serendipity tries to do those subsequent API calls for you in its index.php file and, more specifically, the include/genpage.inc.php file. You can learn from its usage of API calls to stitch your own frontend together.

The more functionality of s9y you want to use, the harder it gets to clone all index.php information. But the more specific you only want certain things (print all comments, print all entries) the easier it gets.

A really simply way of showing entries is outlined here:

http://www.s9y.org/206.html

Of course you could also access MySQL directly, but you'd loose a lot of flexibility like event plugins and such. So if you're willing to dive into the s9y API, you will surely benefit from that and use it. On the other hand, maybe using Serendipity out of the box and adapting your templates would be the easier variant...

Regards,
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/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

It is late, and maybe I am missing something, but this REALLY looks like it could be handled with a template running the whole site...... but again, it is late and I will revisit this post with a fresher perspective.

Meanwhile, absent a template, I would trust the advice given by both Garvin and Judebert.
=Don=
Post Reply