Making feed only display a preview

Discussion corner for Developers of Serendipity.
Post Reply
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Making feed only display a preview

Post by Hathor »

I was noticing that in Bloglines and other aggregators, some people's blogs only show a teaser - maybe the first 200 words on the post - forcing readers to click and come to the real site if they want to read more.

But mine S9 blogs post the entire entry, so they can read it off site without ever visiting my site.

How do I set it to only display a preview of each entry, instead of the whole entry? Is there something I can do in my rss.php file?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Making feed only display a preview

Post by garvinhicking »

Two things interact with this behaviour:

1. The "Show full feeds" configuration option in your Syndication plugin.

2. If you make use of the "extended" entry area. When you create an entry, what you put into the "body" is shown inside the RSS feed, and "extended" only shown in the full view on your blog. Which of course also depends on the setting of 1.)

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/
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

Okay, Show Full Feeds is set to No.

As for #2, you're saying I have to create a preview, and an extended body for the rest of the article?

But this prevents the full article from showing up on my blog's entry page. I DO want the full article on the entry page. I just don't want it in the feed.

What I am seeing on other blogs is a setting to only display the first 250 characters (or whatever number) of each entry. I know Geeklog has this built into their system as an option. It just automatically cuts off the entry (in an aggregator) and puts a "[...]" after it. That's what I was looking for.

WordPress has an option to create an "excerpt" at the top of the entry, and that is another approach that would work. :)

I'm wondering if there isn't just a simple "get variable" for what I want, but I've searched and searched for it online, and I'm not having any luck finding it.
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

I checked with a friend who uses WordPress, and she says it's an option they can set in "reading options". So, I'm not sure how WP implements it, but I'm confident anything WP can do, S9 can do better. :D
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hathor:

Okay, now that you specify your wish a bit more, I can answer to it more appropriately.

In your case there are a couple of solutions. Be warned though that we do not believe in the concept of trunkating text at about XXX characters. This just plain sucks for every reader.

You can create those solutions:

1. If you definitely want RSS text to be cut, you can create a event plugin which hooks into the 'frontend_display' and checks if $GLOBALS['version'] and $_GET['type'] is set. If yes, you can cut your $eventData['body'] down to XXX characters.

2. You can use the body+extended area fields in your blog. The body acts as your introduction which is also displayed in your RSS fields.
Then you just edit your templates entries.tpl file and modify this part of code:

Code: Select all

            {if $entry.is_extended}
            <div class="serendipity_entry_extended"><a id="extended"></a>{$entry.extended}</div>
            {/if}
to this:

Code: Select all

            <div class="serendipity_entry_extended"><a id="extended"></a>{$entry.extended}</div>
And then your extended text always also shows up on your frontpage.

3. You can patch your include/functions_entries.inc.php file and alter the printEntries_rss() function to only show X characters of your body field.

I suggest the second solution - as you see, indeed s9y is in fact flexible enough to offer several solutions to this behaviour. :-)

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/
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

Yes, those are the sort of options I wanted! The second one is ideal because I can choose what excerpt to use.

However, I did my best to follow your instructions, and it's not working. Here's exactly what I did: there was no entries.tpl file in the subfolder for my template (idea). So I changed the one under "default", then copied it to the "idea" subfolder.

Maybe because my template didn't originally contain its own entries.tpl file, there's something more I need to do, perhaps to the styles.css file?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

No, as soon as you put your entries.tpl file into the idea-directory it should work!

Try to make some other changes like putting "XXXXXXXXXXX" into it to see if changes apply. I see no reason why they wouldn't!

(This change though mit depend on which plugins you're using; if you have the cachesimple plugin for example you first need to purge your cache)

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/
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

garvinhicking wrote:(This change though mit depend on which plugins you're using; if you have the cachesimple plugin for example you first need to purge your cache)

Regards,
Garvin
That was it! :) Thanks once again!
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

Um, one more thing. I can't figure out how to change it in Kubrick, which has a customized entries.tpl.

I think the code that needs changing is one of these bits:
<div class="entrytext">
<p>
{$entry.body}
{if $is_single_entry}
<a id="extended"></a>{$entry.extended}
{/if}
</p>

{if $entry.has_extended and not $is_single_entry and not $entry.is_extended}
<br /><a href="{$entry.link}#extended">{$CONST.VIEW_EXTENDED_ENTRY|@sprintf:$entry.title}</a><br /><br />
{/if}
I tried a couple of things, but no luck.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hathor

Use this:

Code: Select all

                <p>
                {$entry.body}
                <a id="extended"></a>{$entry.extended}
                </p>
Actually the Smarty-logic is quite easy, try to understand what removing the "if" does logically :)

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/
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

Thank you!

I've found some Smarty tutorials, and I'm going to try them out, and hopefully learn more about this stuff. :)
Post Reply