an7_feed_link

iaian7 » code » txp   John Einselen, 3.07.07 (updated 10.04.11)    

an7_feed_link lets you define specific feeds for each section of a site; no longer do sections have to link to themselves. The auto detect RSS link in an “about” page header, for example, can be set up to point at a blog feed or outside feed source instead.

Used as a single tag it outputs an auto-detect feed link for use in a page header. Used as an enclosing tag, it will output a link for use in a page.

It does require some setup in the plugin code; define each of your sections with titles (including the “default” section used for the home page), and then define each of the titles with links. Once setup, however, the plugin will automatically read the section of the current page, and link to the specified title / feed combination, either in a header or link format.

examples

single tag:

<txp:an7_feed_link flavor="rss" title="# feed" />

output (to be used in a page header):

<link href="http://feedurl" title="rss feed" rel="alternate" type="application/rss+xml" />

enclosing tag:

<txp:an7_feed_link flavor="rss" title="# feed" ><img src="feed_icon.png" /></txp:an7_feed_link>

output (to be used elswhere):

<a href="http://feedurl" title="rss feed" rel="alternate" type="application/rss+xml"><img src="feed_icon.png"></a>

plugin setup

The plugin works by referencing two arrays, defined in the plugin code. The first array, “sections”, is used to link every section in your site to a title. You can use any text for a title, and the same one any number of times, but each title used must then be set up with a link in the second array; “feeds”.

// "SECTION" "TITLE",
"default" => "about",
"about" => "about",
"article" => "articles",

// "TITLE" "LINK",
"about" => "http://feedurl1",
"articles" => "http://feedurl2",

tag options

flavor="" — “rss” or “atom”, you can set a default in the plugin, but for headers it’s probably best to insert two tags; one for each flavor.

label="# feed for %" — Text string, the symbol “#” is replaced with RSS or Atom (as set above), and “%” is replaced with the section title specified in the plugin script.

section="" — Instead of auto detecting the section, you can manually set it. Not useful unless you’re setting up a list of feed links.

auto="false" — Enter true, and the plugin will automatically edit the links, replacing “rss” with “atom”, or vice versa, based on the flavor set previously. Only useful if you’re using the default textpattern links, Feedburner links are the same for any type of feed format.

download

an7_feed_link (version 0.3)

installation

Open the downloaded an7_feed_link text file and copy / paste the contents into your Textpattern “install plugin” field (Admin > Plugins). Enable the plugin and edit the code to include your site’s sections and links. Use the tag in your head, or use as an enclosure in your page, and everything should work beautifully.

If you are upgrading, please backup the two arrays containing your settings, as the upgrade will overwrite everything.

version history

Please help improve this plugin by reporting errors, issues, or comments via email

v0.3.0
— public release, tag use changed and expanded, help file written
v0.2.0
— second alpha, setup likely to change
v0.1.0
— alpha release, nothing worked

help and support

These instructions and tag options are listed in the Help file within the plugin.

For questions and support, please visit the an7_feed_link post in the Textpattern Forums.

credits

The thresholdstate.com tutorials were used as the plugin base, and php.net served as code reference.

bookmark