Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-08-08 14:22:34

frotzed
Member
From: Planet Earth
Registered: 2007-05-08
Posts: 20
Website

Customising rss feed

First, my apologies. I’m great at XHTML and CSS but I’m crap with PHP. I’d try to figure this out on my own but really, I’m that ignorant of PHP.

I’d like my feed to display like this site’s feed: http://anarchaia.org/index.atom

My blog is layed out very similarly. I’m stripping post titles and just publishing the <txp:body />. I’d really like to tweak my feed so it as well does not display the post title, just the body. Also, I’d like the body to include the links I include in the body, just as the anarchaia feed does.

So, that’s what I’d like on all my sections EXCEPT the section named “journal”. Those posts I would like to appear in the feed as normal.

I know I’m asking a lot here, but whoever helps me out I’ll totally give you a shout out from my blog.


Ben Gray | ben@openswitch.org | http://openswitch.org

Offline

#2 2007-08-08 18:43:35

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Customising rss feed

Well, firstly you don’t need any php-coding-skills to do that. A plugin and some pagetemplate and couple of txp-forms could simply do that.

1. Install and activate plugins mg_setheader and jad_oldposted
2. Create new page-template, like rss with code something similiar to this:

<txp:mg_setheader /><?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<generator>http://textpattern.com/</generator>
<title><txp:sitename /></title>
<link><txp:site_url /></link>
<description><txp:site_slogan /></description>
<copyright>Copyrights (c) <txp:php>echo gmdate( "Y" );</txp:php> <txp:sitename />. All rights reserved.</copyright>
<pubDate><txp:php>echo gmdate( "D, d M Y H:i:s T" );</txp:php></pubDate>
<txp:article_custom allowoverride="0" form="rss-item" limit="20" pgonly="0" section="section" sort="Posted desc" />
</channel>
</rss>

3. In article-form rss-item:

<item>
<title><txp:title /></title>
<description><![CDATA[
<txp:if_article_section name="journal">
<txp:article_image />
<txp:body />
</txp:if_article_section>
]]></description>
<link><txp:permlink /></link>
<pubDate><txp:jad_oldposted format="D, d M Y H:i:s" /> GMT</pubDate>
<dc:creator><txp:author /></dc:creator>
<guid><txp:permlink /></guid>
</item>

4. Create new section, like rss-feed and implent it with pagetemplate named rss. You should check all options of this section off. Now it’s done. In yoursite.com/rss-feed/ you have new nice feed layout. Continue styling it, and you would recieve miracles :-)

Cheers!

Last edited by Gocom (2007-09-04 15:08:40)

Offline

#3 2007-08-08 19:29:24

frotzed
Member
From: Planet Earth
Registered: 2007-05-08
Posts: 20
Website

Re: Customising rss feed

Looks like it’s working: http://openswitch.org/rss-feed.

It even validates!

FYI: here’s what my rss-item form ended up looking like:

<item>

<txp:hide>———— Journal —————</txp:hide>

<txp:if_article_section name=“journal”>
<title><txp:title /></title>
<description><![CDATA[
<txp:article_image />
<txp:body />
]]></description>
<link><txp:permlink /></link>
<pubDate><txp:jad_oldposted format=“D, d M Y H:i:s” /> GMT</pubDate>
<dc:creator><txp:author /></dc:creator>
<guid><txp:permlink /></guid>
</txp:if_article_section>

<txp:hide>———— Thought —————</txp:hide>

<txp:if_article_section name=“thought”>
<description><![CDATA[
<txp:body />
]]></description>
<link><txp:permlink /></link>
<pubDate><txp:jad_oldposted format=“D, d M Y H:i:s” /> GMT</pubDate>
<dc:creator><txp:author /></dc:creator>
<guid><txp:permlink /></guid>
</txp:if_article_section>

<txp:hide>———— Conversation —————</txp:hide>

<txp:if_article_section name=“conversation”>
<description><![CDATA[
<txp:body />
]]></description>
<link><txp:permlink /></link>
<pubDate><txp:jad_oldposted format=“D, d M Y H:i:s” /> GMT</pubDate>
<dc:creator><txp:author /></dc:creator>
<guid><txp:permlink /></guid>
</txp:if_article_section>

<txp:hide>———— Photo —————</txp:hide>

<txp:if_article_section name=“photo”>
<description><![CDATA[
<txp:article_image />
<txp:body />
]]></description>
<link><txp:permlink /></link>
<pubDate><txp:jad_oldposted format=“D, d M Y H:i:s” /> GMT</pubDate>
<dc:creator><txp:author /></dc:creator>
<guid><txp:permlink /></guid>
</txp:if_article_section>

<txp:hide>———— Quote —————</txp:hide>

<txp:if_article_section name=“quote”>
<description><![CDATA[
<txp:body />
]]></description>
<link><txp:permlink /></link>
<pubDate><txp:jad_oldposted format=“D, d M Y H:i:s” /> GMT</pubDate>
<dc:creator><txp:author /></dc:creator>
<guid><txp:permlink /></guid>
</txp:if_article_section>

<txp:hide>———— Url —————</txp:hide>

<txp:if_article_section name=“url”>
<description><![CDATA[
<txp:article_image />
<a href=”<txp:custom_field name=Link%20URL” />”><txp:title /></a><txp:body />
]]></description>

<pubDate><txp:jad_oldposted format=“D, d M Y H:i:s” /> GMT</pubDate>
<dc:creator><txp:author /></dc:creator>
<guid><txp:permlink /></guid>
</txp:if_article_section>

<txp:hide>———— Video —————</txp:hide>

<txp:if_article_section name=“video”>
<title><txp:title /></title>
<description><![CDATA[
]]></description>
<link><txp:permlink /></link>
<pubDate><txp:jad_oldposted format=“D, d M Y H:i:s” /> GMT</pubDate>
<dc:creator><txp:author /></dc:creator>
<guid><txp:permlink /></guid>
</txp:if_article_section>

</item>


Ben Gray | ben@openswitch.org | http://openswitch.org

Offline

#4 2007-09-04 11:27:33

maxvoltar
Member
From: Machelen, Belgium
Registered: 2007-08-16
Posts: 76
Website

Re: Customising rss feed

Hey, thanks for this awsome tip!

I have a small problem, though: My feed is empty :-)

http://www.tenforce.com/feed/

Article code:

<item>
<txp:if_article_section name="blog">
<title><txp:title /></title>
<description><![CDATA[
<txp:excerpt />
<p><txp:permlink>Continue reading “<txp:title />”&hellip;</txp:permlink></p>
]]></description>
<link><txp:permlink /></link>
<pubDate><txp:jad_oldposted format="D, d M Y H:i:s" /> GMT</pubDate>
<dc:creator><txp:author /></dc:creator>
<guid><txp:permlink /></guid>
</txp:if_article_section>
<txp:if_article_section name="press">
<title>Press Release: <txp:title /></title>
<description><![CDATA[
<txp:body />
]]></description>
<link><txp:permlink /></link>
<pubDate><txp:jad_oldposted format="D, d M Y H:i:s" /> GMT</pubDate>
<dc:creator><txp:author /></dc:creator>
<guid><txp:permlink /></guid>
</txp:if_article_section>
<txp:if_article_section name="jobs">
<title>Job Application: <txp:title /></title>
<description><![CDATA[
<txp:body />
]]></description>
<link><txp:permlink /></link>
<pubDate><txp:jad_oldposted format="D, d M Y H:i:s" /> GMT</pubDate>
<dc:creator><txp:author /></dc:creator>
<guid><txp:permlink /></guid>
</txp:if_article_section>
</item>

Page code:

<txp:mg_setheader /><?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<generator>http://textpattern.com/</generator>
<title><txp:sitename /></title>
<link><txp:site_url /></link>
<description><txp:site_slogan /></description>
<copyright>Copyrights (c) <txp:php>echo gmdate( "Y" );</txp:php> <txp:sitename />. All rights reserved.</copyright>
<pubDate><txp:php>echo gmdate( "D, d M Y H:i:s T" );</txp:php></pubDate>
<txp:article_custom allowoverride="0" form="tf_feed" limit="20" pgonly="0" section="blog,press,jobs" sort="Posted desc" />
</channel>
</rss>

Any idea why it’s empty?


Textpattern projects: Maxvoltar, Made by Elephant, Twunch

Offline

#5 2007-09-04 15:06:16

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Customising rss feed

Try removing commas from:

<txp:article_custom allowoverride="0" form="tf_feed" limit="20" pgonly="0" section="blog,press,jobs" sort="Posted desc" />

at the section-attribute. <txp:article_custom />-tag doesn’t support them – or I mean that it doesn’t support multiple sections.

You could use: <txp:article_custom allowoverride="0" form="tf_feed" limit="20" pgonly="0" sort="Posted desc" /> and restrict entries with <txp:if_article_section /> inside article-form.

Cheers!

Last edited by Gocom (2007-09-04 15:09:13)

Offline

#6 2007-09-06 12:58:31

maxvoltar
Member
From: Machelen, Belgium
Registered: 2007-08-16
Posts: 76
Website

Re: Customising rss feed

Thanks Jukka! Works like a charm now!


Textpattern projects: Maxvoltar, Made by Elephant, Twunch

Offline

Board footer

Powered by FluxBB