Recent Topics

1 Aug 14, 2008 16:42    

My b2evolution Version: 2.x

Hi,

I've decided I would like to start using XML excerpts in order to encourage people to actually visit my site instead of just reading everything in Google Reader.

However I probably won't want to do this with all my posts, or explain to the other blogger on my site and ensure that he does this too.

The solution would seem to be to use an XML excerpt where one exists and fall back to "Standard post contents" when there is no excerpt for a post.

Has anyone done this? Is this in any way easy/possible?

2 Aug 14, 2008 17:09

You can edit rss or atom skin and add something like this

if( !empty($Item->excerpt) )
{
    show excerpt
}

For example in rss2 skin edit the followig on line 108

if( $feed_content == 'excerpt' && !empty($Item->excerpt) )

and you should also edit lines 145,150 to just else

}
else
{

It's not tested, but should work ;)

3 Aug 14, 2008 21:54

I think that it should work :)

4 Aug 15, 2008 12:23

Ok, I've done almost the same thing with my RSS2 feed and it seems to work.

Actual changes made:
Your first change (line 108) made as suggested.

if( $feed_content == 'excerpt' ) 

becomes

if( $feed_content == 'excerpt' && !empty($Item->excerpt) ) 

On your second change I did it slightly differently. Mine was a few lines further down from 145 (think I'd made changes to this skin before). I'm sure your way would work fine too, I just wanted to make it more explicit for what I want it to do.

elseif( $feed_content == 'normal'
							|| $feed_content == 'full' )

becomes


elseif( $feed_content == 'normal'
		|| $feed_content == 'full'
		|| ($feed_content == 'excerpt' && empty($Item->excerpt)) )

Also changed the setting in Blog Settings -> Features to Excerpt (now that it falls back instead of posting empty excerpts that's fine).

Result is at: http://www.everythingulster.com/blog/index.php?tempskin=_rss2

5 Aug 15, 2008 12:30

OK, sorry, that's not exactly what I wanted.

Because of the way the code's written (not a mistake/bug, just a consequence): if there's no excerpt that solution gives the full post, not the "standard" or "normal" or whatever its called where it stops at the "Read More" link.

To solve that find the 2 lines just below the second change that say:

if( $feed_content == 'normal' )

and change them both to

if( $feed_content == 'normal' || ($feed_content == 'excerpt' && empty($Item->excerpt)))

6 Aug 15, 2008 15:32

Your feed returned a error 500 right now!

7 Aug 15, 2008 16:31

<?php
$feed_content = ( empty( $Item->excerpt ) ? 'normal' : 'excerpt' );
?>

¥

8 Aug 15, 2008 16:52

Walter wrote:

Your feed returned a error 500 right now!

Works fine for me :\

9 Aug 15, 2008 16:53

¥åßßå wrote:

<?php
$feed_content = ( empty( $Item->excerpt ) ? 'normal' : 'excerpt' );
?>

¥

That would've made sense too, obviously! Where's the "D'oh!" smiley when you need it? Thanks!


Form is loading...