Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Linklog with RSS to Twitterfeed
That’s one way of doing a custom RSS feed. Another way is to use a form with a custom mediatype and utilize the ability to output that form via the url https://yourdomain.com/?f=form_name
. It does basically the same thing without using a section for it.
- Go to Admin › Prefs › Admin and set “Advanced options” to on (if not already. This is a once-only setting).
- Now visit Admin › Prefs › Advanced Options and under “Custom form template types” append something like:
[feed]
mediatype="application/xml"
title="Feed"
- Now visit Presentation › Forms and you’ll see a new form type heading called “Feed”. Add a new form, e.g.
news_feed
and assign it to the new “Feed” form type and put your custom rss code in that. The Content-Type txp:php block at the top is not necessary as the form will automatically be rendered with the mime-type specified under advanced options. - Your form is now accessible via
https://yourdomain.com/?f=news_feed
You can combine this with a mini-plugin to give these clean urls – see this post.
–––
Here’s another (untested) idea of how to do title-less articles: currently you are setting the article title to “untitled” but you’ll find you’ll need to alter the article url title each time to avoid identical article name clashes, e.g. untitled-1
, untitled-2
…
Another way might be able to use the much under-utilised “override form” select box under “Sort and Display” on the write tab. You can use this dropdown to set an article to optionally use a form different from that assigned by default (a nice trick for when you want to do a tumblr-like site with alternating post types). If you make an article form similar to the default
(or whatever you are using) that doesn’t output the title, you can give it whatever title you want in Textpattern but not output it on your page.
For your rss code that would mean detecting which override form is being used, e.g. using the custom_field trick in place of your rss_title
variable:
<txp:if_custom_field name="override_form" value="titleless_article" not>
<title><txp:title /></title>
</txp:if_custom_field>
I’ve not tried this out but that should skip the article title if the override form is set to the form titleless_article
. For all other articles, the title is shown.
What I’ve not understood is how the first X words of a title-less post get emboldened. Does that at the reader’s end? I’ve read the GitHub post properly now: the emboldening is done by that RSS reader script.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Linklog with RSS to Twitterfeed
There are few small problems with manual constructions:
- Title should be xml-escaped, otherwise a lonely ampersand
&
or html entities like
would invalidate the feed. Escaping is more tricky than<txp:title escape />
, since this would convert, say,
into&nbsp;
which is not human readable. - Same for
CDATA
, enclosing body within<![CDATA[...]]>
will not suffice if body contains]]>
. - I’m not sure whether this is really required, but core feeds contain also
<guid />
tags with some article data (uid
andfeed_time
) not available via txp tags.
The first two points can be solved by adding some xml
and cdata
options to the global escape
attribute. The last one needs some thinking. We could delegate ‘content’ fields (title, body, etc) output to a form, and let core append ‘meta’ tags (like guid
). But this needs either a form name convention, or a pref for each feed type (rss/atom). Also, per section feeds would need these forms to be available in each theme.
Offline
Re: Linklog with RSS to Twitterfeed
For the overall blog guid there’s:
<txp:php>echo get_pref('blog_uid');</txp:php>
and for the item uid (with isPermaLink="false"
) you could use the article uid:
<txp:php>global $thisarticle; echo safe_field('uid', 'textpattern', 'ID="'.$thisarticle['thisid'].'"');</txp:php>
I thought <txp:php>global $thisarticle; echo $thisarticle['uid'];</txp:php>
might work but it doesn’t seem to.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Linklog with RSS to Twitterfeed
Sure you could, but this requires an extra db call per article and is not very user friendly, even if we add uid
and feed_time
to $thisarticle
array (which would overwrite eventual cf named uid
and feed_time
).
Offline
Re: Linklog with RSS to Twitterfeed
etc wrote #334346:
but this requires an extra db call per article and is not very user friendly.
Yes, I agree. It was just the solution I had used up to now.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Linklog with RSS to Twitterfeed
jakob wrote #334338:
That’s one way of doing a custom RSS feed. Another way is to use a form with a custom mediatype and utilize the ability to output that form via the url
https://yourdomain.com/?f=form_name
. It does basically the same thing without using a section for it.
TXP can run a form directly? Mind blown
Offline
Offline