Page 1 of 1

How to not include some entries in RSS feed

Posted: Thu Feb 23, 2006 11:09 pm
by Ed
Hello,

first (it's my first post in this forum) many thanks to Garvin and others contributors for this nice tool that is s9y.

I'm using in my blog some entries as 'summary entries' . These are sticky entries. And i would like that theses entries do not appear in RSS feeds. Doing so, only entries with a consistent content will be send on RSS requests.
Is there an easy way to do it ? (i have to say i'm not an expert in Php)

thanks

Edwige

Re: How to not include some entries in RSS feed

Posted: Thu Feb 23, 2006 11:21 pm
by garvinhicking
Hi Edwige!

Thanks for your kind words. :-)

Luckily, I can tell you good news about your request. Serendipity as of 0.9 (I hope...I couldn't really tell, but if my memory serves me right, it should be in 0.9. But it's definitely in 1.0-beta1) allows to do that with the extra-help of the plugin "Extended Properties for Entries". It's an event plugin that is shipped by default with Serendipity.

Once active, you have additional options for each entry below the editing form, where you can also check the Option "Hide content from RSS feed".

I hope that was what you looking for. If that does not actually do what you want, just report back and we'll see what can be done for you. There are some cool things that can be done for you if you use Serendipity 1.0-beta, then we could abuse the "Custom Fields" option of the same plugin for some cool extra-tidbits.

Regards,
Garvin

Re: How to not include some entries in RSS feed

Posted: Thu Feb 23, 2006 11:26 pm
by garvinhicking
Thinking a bit about it, I figure you want to COMPLETELY hide the entry from your RSS feed.

Then I suggest doing the following with Serendipity 1.0-beta1 or a recent snapshot:

1. Install the 'Extended properties for entries' plugin
2. Configure that plugin and in the "Custom Field" section add the field "hiderss"
3. Create an entry, go to the bottom of the screen where you see "hiderss" with an input field. Enter "yes" there.
4. Now edit your templates/XXX/feed_*.tpl files (copy the files from the default template, if those do not exist in your template folder)
5. Inside the files you will see something like this:

Code: Select all

{foreach from=$entries item="entry"}
<item>
    <title>{$entry.feed_title}</title>
    <link>{$entry.feed_entryLink}</link>
    {foreach from=$entry.categories item="cat"}
        <category>{$cat.feed_category_name}</category>
    {/foreach}

    <comments>{$entry.feed_entryLink}#comments</comments>
    <wfw:comment>{$serendipityBaseURL}wfwcomment.php?cid={$entry.feed_id}</wfw:comment>

{if !$is_comments}
    <slash:comments>{$entry.comments}</slash:comments>
    <wfw:commentRss>{$serendipityBaseURL}rss.php?version={$metadata.version}&type=comments&cid={$entry.feed_id}</wfw:commentRss>
{/if}    

    <author>{$entry.feed_email} ({$entry.feed_author})</author>
{if !empty($entry.body)}
    <content:encoded>
    {$entry.feed_body|@escape} {$entry.feed_ext|@escape}
    </content:encoded>
{/if}

    <pubDate>{$entry.feed_timestamp_r}</pubDate>
    <guid isPermaLink="false">{$entry.feed_guid}</guid>
    {$entry.per_entry_display_dat}
</item>
{/foreach}
Don't be afraid of this code! We just need to insert a single "if" check that checks if the property 'hiderss' of an entry is set to 'yes', and only if that is not set, the feed will be shown. For that, I add an IF-check directly below the FOREACH loop:

Code: Select all

{foreach from=$entries item="entry"}
{if $entry.properties.ep_hiderss != 'yes'}
<item>
    <title>{$entry.feed_title}</title>
    <link>{$entry.feed_entryLink}</link>
    {foreach from=$entry.categories item="cat"}
        <category>{$cat.feed_category_name}</category>
    {/foreach}

    <comments>{$entry.feed_entryLink}#comments</comments>
    <wfw:comment>{$serendipityBaseURL}wfwcomment.php?cid={$entry.feed_id}</wfw:comment>

{if !$is_comments}
    <slash:comments>{$entry.comments}</slash:comments>
    <wfw:commentRss>{$serendipityBaseURL}rss.php?version={$metadata.version}&type=comments&cid={$entry.feed_id}</wfw:commentRss>
{/if}    

    <author>{$entry.feed_email} ({$entry.feed_author})</author>
{if !empty($entry.body)}
    <content:encoded>
    {$entry.feed_body|@escape} {$entry.feed_ext|@escape}
    </content:encoded>
{/if}

    <pubDate>{$entry.feed_timestamp_r}</pubDate>
    <guid isPermaLink="false">{$entry.feed_guid}</guid>
    {$entry.per_entry_display_dat}
</item>
{/if}
{/foreach}
Now save that file, and now the feed will only display items where this "hiderss" field is not set to "true". :-)

Have fun,
Garvin

Re: How to not include some entries in RSS feed

Posted: Fri Feb 24, 2006 12:16 am
by Ed
Hi Garvin,

Effectively, i want to completely hide these entries (i.e. not included at all in RSS results requests).
I had seen the "Extended Properties for Entries" plugin, and, as you said, it only mask entry's content, not all entry.

I think i've anderstood the code and the procedure you suggest (with a such speeeeeddd, wouah !!! ) .
I'll try that as soon as i can. And will say here the result.

many thanks !

Edwige

Re: How to not include some entries in RSS feed

Posted: Fri Feb 24, 2006 2:04 pm
by Ed
Hello Garvin,

it works like a charm. And I like the power of this extended properties plugins.

Many thanks
Edwige

Re: How to not include some entries in RSS feed

Posted: Fri Feb 24, 2006 2:05 pm
by garvinhicking
Great to hear that! :-)

Have fun with Serendipity,
Garvin