Embedding the latest blog entry on my website

Having trouble installing serendipity?
kipinae
Regular
Posts: 14
Joined: Sat Aug 26, 2006 6:59 pm

Embedding the latest blog entry on my website

Post by kipinae »

So, I thought I'd revamp my site completely, and with the update I thought I'd include the latest blog entry on the actual website, and only a link with it to the "whole blog", which I've had for some while now already.

I have been messing around with the .php files for hours now, browsing the forums and whatnot, and I just can't seem to get it show any kind of blog on my page.

So what I want is the latest blog entry to show here: http://kitsunest.net/blog.php . I'd add a link to the actual blog above it or something, if people want to read earlier entries etc. Serendipity is currently installed on http://kitsunest.net/blog/index.php .

I have tried the wrapper method but I guess I'm doing something wrong because I can't seem to get it to work.

So what files need to be edited/moved/created and how/where to make it work? Any help would be appreciated, I'm pretty lost here. :D
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Embedding the latest blog entry on my website

Post by garvinhicking »

Hi!

Have a look at this thread:

http://www.s9y.org/forums/viewtopic.php ... tchentries

HTH!

Best 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/
kipinae
Regular
Posts: 14
Joined: Sat Aug 26, 2006 6:59 pm

Post by kipinae »

Sorry for the late reply, and thanks for the help. :) I looked at the thread you gave a link to, but it was no big help because the other guy apparently figured most of it by himself but never wrote what was wrong.

So I still haven't got it working, the plugin is probably too complicated for idiots like me. :D
I'd understand if it showed some kind of error in the page, but now it shows absolutely nothing, when I have this included in my blog.php:

Code: Select all

<script src=public_html/blog/serendipity_event_backend/></script>
I dunno if I got it all wrong with the URLs or what, I'm completely lost with this. In the plugin configuration in the Serendipity admin panel I have entered http://kitsunest.net/blog.php?/blog/ser ... t_backend/ , I just figured it would be something along those lines according to the example URL in the config page.

Is the problem either of these, or something else?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

I mentioned several methods in that thread, did you check out all of them? You seem to have sticked with the JS backend-Solution.

Code: Select all

<script src=public_html/blog/serendipity_event_backend/></script>
That is wrong. First you need to pass a filename to the 'src' attribute of the javascript. The link you need to use is described in the plugins README file.

Second you need to pass a URL in the 'src' attribute, not a local directory. :)

So you might want to check out the other options I mentioned in the thread that I linked, or stick to the readme of the plugin to properly load the javascript. Use Firefox and have a look at the Error / Javascript console to debug problems.

Best 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/
kipinae
Regular
Posts: 14
Joined: Sat Aug 26, 2006 6:59 pm

Post by kipinae »

I sticked with the plugin because I have even less experience with RSS (none :D) than I have with PHP, and the code snippets were out of question because I understand a very minimal amount of German, so I'd be pasting all the wrong codes anyway. :)

The readme is being kinda hard to follow because the example URLs are not even close to what it really looks like inside the Serendipity directory, for example my path to the plugin folder in question is something like /blog/plugins/serendipity_event_backend/ where in the example it's http://your.blog.com/plugin/[BACKEND_URL]?[OPTIONS].

So if I start building the <script src> like the readme tells me to, I end up with something like this:

Code: Select all

<script src="http://kitsunest.net/blog.php?/blog/serendipity_event_backend/serendipity_event_backend.php?details=1&num=1"></script>
which seems so very wrong even to me...and doesn't work.

I'm not even sure if I'm linking to the right file, there's that serendipity_event_backend.php and backend.html - I guessed the first because it's .php. In the Serendipity plugin config field I put

http://kitsunest.net/blog.php?/blog/ser ... ackend.php, just like in the src code.

About the Error/JavaScript console - I tried using it but the only thing it gives me an error (on my blog.php) is about the doctype, I don't think that's got to do anything with this problem.

Care to shed some light on my problem? :D
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

"BACKEND_URL" is the configuration value you gave the backendplugin as the title. Say you called it "myownentries" you would call http://yourblog/plugin/myownentries.

NOTE WELL that the path was "/plugin/"! This is not like "/plugins/"! So the path you have needs to stay with http://kitsunest.net/plugin/myownentries.

If you do not use URL rewriting, you need to use http://kitsunest.net/index.php?/plugin/myownentries instead.

As you can see, the URL is dynamic. You call the serendipity frontend, and NOT a specific plugin file at all.

Best 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/
kipinae
Regular
Posts: 14
Joined: Sat Aug 26, 2006 6:59 pm

Post by kipinae »

No wonder nothing's happening. :D

Three things:

1. Where can I see my "BACKEND_URL" configuration value?
2. Do I need to have something in that /plugin/ folder, or is it "just for show"?
3. What does "URL rewriting" mean?

Thanks for your patience. :)

EDIT//

I think I figured what the backend thing means - and I put http://kitsunest.net/index.php?/plugin/ ... ls=1&num=1 in the script src, and the same without the "details" and "num" thingies in the plugin config at Serendipity. Is that right?

I'm still getting a blank blog at http://kitsunest.net/blog.php though - still missing something?
suprdave71
Posts: 1
Joined: Fri Sep 01, 2006 7:35 pm

Complicated

Post by suprdave71 »

I'm sorry, but this has been so frustrating!

I've tried to embed Serendipity for hours now, and I've gotten nowhere. I generally end up with a blank page, though I've followed directions implicitly.

I'm using a Dreamweaver Template for my site. There is an editable area of the site where I can include whatever I wish. The page is saved as a .php document, though the bulk of its contents are generated with html and css.

When I try a absic include function, I get nothing. I've tried the javascript plugin that you've been describing here. Again, I've followed every tidbit of advice and the documentation around this site — I get a blank page.

Can you think of a reason this wouldn't be working for me? Does the Dreamweaver template have something to do with it?

Oh, and when I use the directions to create a wrapper file, the page goes to serendipity_admin.php and I get an error that I can't access that page.

I'm willing to try anything, and I'll post my results here in better detail. I've just tried so many things that I can't remember what the results were for each of them....

Thanks!
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

I'm starting to hate embedding. I tried to write a more detailed embedding tutorial on the main site, but apparently people keep running into additional problems.

I don't use DreamWeaver, but I understand that some of its templates and plugins use Javascript code that messes up other Javascript. And some plugins are Windows-only ActiveX controls.

I assume you've created a wrapper file that changes to the Serendipity directory, saves the Serendipity output to a variable, and returns to the original directory. I further assume you've made no changes to Serendipity otherwise, configuration or plugin. If this is all correct, can you show me a snippet where you call the wrapper file? I'll see what I can do.
Judebert
---
Website | Wishlist | PayPal
kipinae
Regular
Posts: 14
Joined: Sat Aug 26, 2006 6:59 pm

Post by kipinae »

Update on my situation, I finally got the blog showing when I tried the wrapper method, BUT it's of course showing the whole things with all the sidebars and stuff.

Now, how do I get rid of the blog layout inside the embedded page and still keep the blog layout as it is when I want to visit the "real" blog?

That is, no hiding sidebars and enabling embedded Serendipity in its config.

EDIT//

I thought I should mention that I did try the Magpie way as well, but didn't get it working either. I either got nothing or errors.

I think I need some sleep now, it's 3.30 AM and I've been struggling with this and other scripts for nearly 12 hours in a row now...

EDIT2//

Another sidenote, when I'm using (or trying to use) the plugin method, I have "entries" typed in the plugin configuration at the Serendipity admin panel, and http://www.kitsunest.net/index.php?/plu ... m.Y&time=0 as the script src. I ve tried the also with the shorter form without the index.php? part, and without the www with both options.

And with this I get a blank page, not even errors.

Does the script need something more in my blog.php to work?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

I'm really sorry for your situation! It can definitely be difficult, if you don'T yet know how serendipity puts everything together. :)

Since you seem to got most of the way with some coding, I figure you'll be able to solve the additional task at hand.

You want to conditionally either "embed" your blog if viewed from within a PHP script, or unembedded when being viewed straight.

Actually the main serendipity framework is not meant to be runnable as both, embedded and non embedded. The reason is that s9y needs to put the target links to either your embed script, or to the main serendipity script - but both is conditionally currently hard to achieve.

There are two ways to cope with that situation.

The one is to NOT use the s9y embedded mode. Instead put the PHP code into your dreamweaver page. I actually mentioned that in the thread above, it would read something like this:

Code: Select all

<html>
... your dreamweaever code ...

<div class="blog">
<?php

// Change to Serendipity
chdir('/path/to/serendipity');

// Include Serendipity API
include 'serendipity_config.inc.php';

// Startup Smarty Template Processing
serendipity_smarty_init();

// Fetch current entries.
$entries = serendipity_fetchEntries();

// Parse current entries.
serendipity_displayEntries($entries);

// Display current entries template.
$serendipity['smarty']->display(serendipity_getTemplateFile('entries.tpl'));
?>

... rest of your dreamweaver code ...
</html>
That should be most versatile and flexible, since you can access all of the s9y API functions (most of the are documented in the technical docs on www.s9y.org up to some point).

Now there other way would be to edit your index.tpl template file to check if embed-mode is required or not. You would define a PHP constant in your php code where you include serendipity, like 'define('IS_EMBED', true)'. In your template you then replace all the {if $is_embed} calls to {if $CONST.IS_EMBED}. Now this constant will only be set when you call s9y from your DW template, and NOT when calling it from the usual URL.

So, I think this should keep you playing for some more hours :)

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

Post by garvinhicking »

BTW: Your script url is still wrong. You are not allowed to use "?" multiple times.

Use:

http://www.kitsunest.net/blog/index.php ... m.Y&time=0

BUT: You should NOT use 'entries' as your backend-plugin name. This is a reserved word. Sorry for the hassle, as it's not properly documented. Use "articles" instead, maybe? then the URL would be:

http://www.kitsunest.net/blog/index.php ... m.Y&time=0

after you changed the path in the plugin config.

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/
kipinae
Regular
Posts: 14
Joined: Sat Aug 26, 2006 6:59 pm

Post by kipinae »

I tried the piece of code you gave and apparently it's at least doing something because I get a couple of errors. :D

So here's what I put into my blog.php...

Code: Select all

<div class="blog">
<?php

// Change to Serendipity
chdir('blog');

// Include Serendipity API
include 'serendipity_config.inc.php';

// Startup Smarty Template Processing
serendipity_smarty_init();

// Fetch current entries.
$entries = serendipity_fetchEntries();

// Parse current entries.
serendipity_displayEntries($entries);

// Display current entries template.
$serendipity['smarty']->display(serendipity_getTemplateFile('entries.tpl'));
?>
...and these are the errors it gives me.
Warning: Cannot modify header information - headers already sent by (output started at /home/pt4604/public_html/blog.php:8) in /home/pt4604/public_html/blog/include/functions_config.inc.php on line 418

Fatal error: Call to undefined function: serendipity_displayentries() in /home/pt4604/public_html/blog.php on line 91
I don't know what's in the functions_config.inc.php on that particular line, but on blog.php line 91 says
serendipity_displayEntries($entries);
Any ideas where to go next? :D

Thanks for correcting the plugin urls as well, though I still can't seem to get that work either. Apparently it's now also doing something, because it lifted my footer inside my 'content' in the layout...
I changed the name 'entries' into 'articles' too.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Ah! You're right, I'm sorry. Those two lines:

Code: Select all

<?php

// Change to Serendipity
chdir('blog');

// Include Serendipity API
include 'serendipity_config.inc.php';
must be at the top of your dreamweaver script! It is neccessary that serendipity's framework is included before anything else. :)

Then I made a spelling mistake. :( The function I meant was not serendipity_displayEntries() but serendipity_printEntries()!

BTW, try this:

http://www.kitsunest.net/blog/index.php ... ?details=1
http://www.kitsunest.net/blog/index.php ... n/articles

those should emit proper javascript, I think! :-)

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/
kipinae
Regular
Posts: 14
Joined: Sat Aug 26, 2006 6:59 pm

Post by kipinae »

With that new URL the Java plugin seems to work fine, I'm seeing entries now. :) Now, what should I add to the url to make only one entry show, or do I config that somewhere else?

Thank you so much for all your help and patience, I'll be sure to support you once I (in the hopefully-not-so-distant future) get my credit card and am able to use Paypal. :)

EDIT//

Nothing, I got it to show only the latest entry. :D I wish I could have the date before the entry instead of after it though.

And I noticed it's lifting my footer inside the content again, I guess there's some simple fix for that?
It's showing beneath the blog entry, inside my content, and it should span below the whole layout like on all the other pages.
Last edited by kipinae on Sat Sep 02, 2006 1:48 pm, edited 1 time in total.
Post Reply