A bottled Geenie-wondertag for textpattern

The Gordian Knot

One common limitation, that you might hit sometimes, when using TXP after some while, is to overcome the limitation to supply txp functions as attributes for other TXP-tags.

Normaly, this would require a PHP include. No good news, if you are not trained in PHP.

Wet has pretty much documented everything, that could be sayd about it.

However, things have become a little easier now, thanks to Sencers magic asy_wondertag plugin

A new Child is born, a Child in a Bottle.

Usage is pretty simple. Just wrap the code portion, that contains the txp or even (plugin tag), that needs an other tag supplied as an attribute, and asy_wondertag will do all the rest for us.

Let's try out and see.

Usage example for a Tech-news section

For a practical example: Let's say we want a Tech News Section on a Section Landing Page called Tech-news and we want to pull in a couple of Feed Title links in there.

Each time I publish a Tech-news article, I'd like to keep the corresponding news feed link, that points to the corresponding promoted Site in a custom Field, and have the last feeds show up in the Tech-news section.

The Ingredients

We set up the custom field, and name it tech-news

Next, we need the corresponding plugins. The first one was already mentioned above, and second one we need, is bit_rss from Bit Santos

The Plan

Starting from the Section Page Template, we put everything we need here in an output_form, to keep our page a little organized.

Below is, what I put in my page template.

<txp:output_form form="gen_section_tech" />

Note:This needs to be stored as a miscallaneous form.

Next, we use an article_custom tag and limit the scope to the tech-section using a conditional, as shown below. Setting the limit attribute to 5 should be enough, to always get a maximum of the latest 5 external headline feeds.

<txp:if_section name="tech-news"><h2>Latest Tech News</h2><ul id="tech-news"><txp:article_custom form="gen_tech_news" limit="5" section="tech-news" /></ul></txp:if_section>

The form used here, which is named gen_tech_news contains our main plugin-tag, with the corresponding feed supplied as value through our pre made custom_field

We have reached the critical barrier. Would pouring everything in Sencers magic bottle be enough?

Let's see.

Another thing here, is that we still need to wrap the whole thing in an if_custom_field conditional, or else the feed plugin might throw some errors at us, in case there is no feed supplied in our custom field, or it has been forgotten to be inserted.

<txp:if_custom_field name="tech-news"><txp:asy_wtag><txp:bit_rss feed='<txp:custom_field name="tech-news" />' limit="1" form="gen_bit_section_atom" /></txp:asy_wtag></txp:if_custom_field>

What we basically need here, from our feeds is just the permlinked title, since we don't want to waste a lot of space and bit_rss allows for a form attribute as well, which is named gen_bit_section_atom here and shown below.

<li class="tech"><h3><txp:permlink><txp:title /></txp:permlink></h3></li>

Note, that this needs to be stored as an article form.

That's basically it. Now towards the interesting question:

When I open the bottle, will the wonder happen?

Oh, yes it does

Caveats

There is no caveats. You just need to set up and configure the feed plugin correctly together with the simplepie include, make sure cashing is used, and also garantee, that you supply working and valid feeds, which is rather the trickier part of the story.

More Usage Examples

Some Usage examples for asy_wondertag, can be found here, on Alex's Site.

Note: Website content is in German.