HTML Embed

Having trouble installing serendipity?
Post Reply
jbensous
Posts: 1
Joined: Sun Mar 12, 2006 10:21 pm

HTML Embed

Post by jbensous »

Hi,

I got everything installed fine. I do not use php pages on my website I use regular HTML files, except the index page. Basically it is setup as an HTML page, with one line of php code to include the news posts. How can I embed the blog into my index.php page? I do not want any headers/footers or anything else, just the blog post entries. I can do this with my current news/blogger Fusion PHP. Basically I just use a single line of code to embed the news posts into the index.php file on my server for Fusion.

I set the config to embed but it still shows the right column. Can you please assist? The index.php file in serendipity still brings up the right colum stuff even after the option is set to embed. Can I change it to be news.php instead of index.php ??

Also, on my main page I only want to include the latest headline/blog entry and they will click to a page that has them all for that month... can i link directly to a blog entry - or can i set it where it automatically grabs the latest headline and puts it there? Just ONE - not all of them. I have another page setup for all of the news/blog entries.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: HTML Embed

Post by garvinhicking »

Hi!

Yes, serendipity can also be used as some kind of "API".

You can use that piece of code:

Code: Select all

<?php
chdir('path/to/serendipity'); // Switch to Serendipity patch
include 'serendipity_config.inc.php'; // Include framework
serendipity_smarty_init(); // Start Smarty templating framework
serendipity_printEntries(serendipity_fetchEntries(null, true, $serendipity['fetchLimit'])); // Fetch the latest entries and parse them into Smarty template
$serendipity['smarty']->display(serendipity_getTemplateFile('entries.tpl', 'serendipityPath')); // Output the entries template
?>
With that code, Serendipity prints the entries as templated in the 'entries.tpl' file.

This is the most flexible solution to use Serendipity inside your Application.

The "Embed" mode would work fine, but it's targetted at other cases, where you want a full serendipity to be embedded into your page. But you said you only wanted to see the entries.

You can adapt what is printed by looking into the serendipity files (include/functions_entries.inc.php) where the functions are documented for changing.

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/
godfather
Regular
Posts: 19
Joined: Mon Apr 04, 2005 8:06 pm

Post by godfather »

I got this exact thing to work, but when you follow a link, the results dont appear in the embedded page. Is there a way to remove links such as title, author, etc, or make links appear in the same page?

Other than that this works PERFECT!! Booyah.

Thanks as always Garvin! :lol:
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

That's true, links always lead to the "full s9y installation". If you did not want that, the code from above would need to change it to something like this:

Code: Select all

<?php
chdir('path/to/serendipity'); // Switch to Serendipity patch
include 'serendipity_config.inc.php'; // Include framework
$serendipity['indexFile'] = 'myindex.php'; // Target page
$serendipity['rewrite'] = 'none'; // Force no rewriting so that myindex.php is used
serendipity_smarty_init(); // Start Smarty templating framework
serendipity_printEntries(serendipity_fetchEntries(null, true, $serendipity['fetchLimit'])); // Fetch the latest entries and parse them into Smarty template
$serendipity['smarty']->display(serendipity_getTemplateFile('entries.tpl', 'serendipityPath')); // Output the entries template
?> 
You can remove template items by copying entries.tpl to 'myentries.tpl' and specify that filename in the serendipity_getTemplate() function call.

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/
mugs
Regular
Posts: 48
Joined: Wed Sep 27, 2006 2:16 pm

Post by mugs »

can't seem to get the template working with this, it's like a stale html page without the styles
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Maybe the php file has a fatal parse error, which can result in plang pages.
Have a look at your php/apache error logs, and maybe check if your display_errors directive of php.ini (see phpinfo() output) is enabled?

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/
mugs
Regular
Posts: 48
Joined: Wed Sep 27, 2006 2:16 pm

Post by mugs »

actually the page loads and the content is showing but the styles are not loading i am attaching the link
http://www.mugsinc.com/listindex.php
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Sure, just have a look at the HTML output you get. There are no <html> headers. If you use the s9y embed option you need to take care of emitting HTML headers and CSS links yourself. :)

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/
mugs
Regular
Posts: 48
Joined: Wed Sep 27, 2006 2:16 pm

Post by mugs »

i am new to all of this, could you help me out with how this can be done
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
mugs wrote:i am new to all of this, could you help me out with how this can be done
What do you want to achieve with the embed mode? Why do you not use the simple non-embedded serendipity mode? Embed mode is for people who know what they do with the PHP code snippet, so my guess is that it's not suited for what you want to do?

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/
mugs
Regular
Posts: 48
Joined: Wed Sep 27, 2006 2:16 pm

Post by mugs »

what is the simple non-embedded serendipity mode
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
mugs wrote:what is the simple non-embedded serendipity mode
Using serendipity without any extra PHP code like you posted. Without having the Serendipity Configuration option "Use embedded mode" activated.

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/
Post Reply