Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-09-12 15:13:13

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

asy_wondertag (tags-in-tags/tags as attributes)

So, finally, after one too many questions of whether “tags in tags” (meaning tags in attributes) works and somebody on the forum reformulating it mechanically as a php-snippet, I wrote a plugin that should handle most of those cases. Details below.

This plugin has been payed for by: marios, wet, jakob, ma_smith, Ace of Dubs, Pixilate, Dennis Frank.
Download: http://www.sencer.de/code/txp/asy_wondertag.txt

asy_wondertag – a ‘hack’ for using tags as attributes

asy_wondertag allows the use of tags as attributes in limited circumstances (hey, it’s a hack, don’t expect it to work with anything you throw at it). This is useful for allowing the somewhat more flexible use of some tags, for example by using meta-data (from url-parameters or custom-fields) in attributes. Before using this plugin, think about whether you can reorganize your content or templates in a different fashion, that doesn’t require using tags as attributes.

How to use & Examples

Simply wrap <txp:asy_wondertag></asy_wondertag> around the tag where you intend to use a tag as an attribute. It can be used with either a self-closing tag, like <txp:article_custom />, or with tags that consist of a start- and end-tag like <txp:if_article_category>...<txp:if_article_category>. This does not work

Examples:

1)
<txp:asy_wondertag><txp:article_custom form="lofi" section="<txp:s /></txp:asy_wondertag>

2)
<txp:asy_wondertag><txp:article_custom form="lofi" section="<txp:php>echo 'something';</txp:php>" /></txp:asy_wondertag>

3)
<txp:asy_wondertag><txp:if_article_category name="<txp:custom_field name="test" />">
This matches.
<txp:else />
No match here.
</txp:if_article_category></txp:asy_wondertag>

DISCLAIMER: What this plugin is not.

This plugin is not a proper parser, it doesn’t understand your syntax, it only makes some substitutions (based on conventions) and hopes for the best. This works suprisingly well for a lot of cases, but likely barfs on more complex syntax (it’s a hack, I told you). Specifically do not wrap this tag around whole forms or pages – it’s just not going to work. Instead use it where it is needed, and wrap it around one tag. You can set production mode to debug and watch the tag-trace to see whether it worked. Do not try to nest this tag inside itself. The magic is usually only enough to handle one tag as one attribute per invocation (except for some exceptions with self-closing tags).

Last edited by Sencer (2006-10-07 08:47:30)

Offline

#2 2006-09-12 18:20:11

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: asy_wondertag (tags-in-tags/tags as attributes)

Nice Idea Sencer, somewhat like a bottled Genie. Would it be possible to give a small list of tags on which it works ?

(couldn’t load PayPal page)

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

#3 2006-09-12 18:40:04

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: asy_wondertag (tags-in-tags/tags as attributes)

It’s not restricted to certain tags. I should work with any kind of tag, including plugins.
It’s just that there are (probably) some ways of calling it, that are not going to work. Hence my offer to try out different code-snippets for people who think about contributing to this plugin. I will post those tests/examples that do not work here in this thread.

Offline

#4 2006-09-12 19:25:15

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

Re: asy_wondertag (tags-in-tags/tags as attributes)

Let’s try this:

<txp:zem_contact to="<txp:custom_field name="who" />" subject="<txp:php>echo gps('where').' - '</txp:php><txp:custom_field name="what" />" />

Thanks!

Offline

#5 2006-09-12 21:11:24

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: asy_wondertag (tags-in-tags/tags as attributes)

wet wrote:

Let’s try this:

Hi wet,

seems to work fine (after changing “to” to “mailto” and adding a semi-colon in the php-code):

<txp:asy_wtag><txp:zem_contact mailto="<txp:custom_field name="who" />" subject="<txp:php>echo gps('where').' - ';</txp:php><txp:custom_field name="what" />" /></txp:asy_wtag>

returns an email-form. The tag-trace is as follows (I had previously added the custom fields, and a “where”-query parameter, when accessing the page):

<txp:asy_wtag>
		<txp:custom_field name="who" />
		<txp:php>
		</txp:php>
		<txp:custom_field name="what" />
		<txp:zem_contact mailto="admin@example.org" subject="there - stuff" />
			[SQL (0.000247): insert into txp_discuss_nonce set issue_time=now(), nonce='95c9f184c646a122b561e75a04e5ba37']
			<txp:zem_contact_text label="Name" />
			<txp:zem_contact_email/>
			<txp:zem_contact_textarea/>
			<txp:zem_contact_submit/>
	</txp:asy_wtag>

Though I should add that using several tags on several attributes only works for self-closing outer-tags (see the last sentence of the disclaimer).

Last edited by Sencer (2006-09-13 12:16:38)

Offline

#6 2006-09-12 21:32:16

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,578
Website

Re: asy_wondertag (tags-in-tags/tags as attributes)

sounds good sencer, I’ve added to the fund.


TXP Builders – finely-crafted code, design and txp

Offline

#7 2006-09-19 08:07:09

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: asy_wondertag (tags-in-tags/tags as attributes)

Thanks to 5 contributers (marios, wet, jakob, Pixilate, Dennis Frank), the ransom is already at 60%.

If anybody has a question they like answered before contributing, I am available via email (or in this thread).

Offline

#8 2006-09-30 07:58:22

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: asy_wondertag (tags-in-tags/tags as attributes)

Thanks to marios (again), and to ma_smith, in additition to the people mentioned above, who helped complete the ransom. The plugin is now available for download.

I have edited the opening post with the download link.

Offline

#9 2006-10-17 18:25:34

jamiew
Archived Plugin Author
From: NYC
Registered: 2005-01-08
Posts: 74
Website

Re: asy_wondertag (tags-in-tags/tags as attributes)

Any plans to move this logic into crockery? Granted it’ll open a whole can of worms, but it’s usefulness is undeniable. I’ve written many a plugin that this could have solved!

Offline

#10 2006-10-17 19:07:23

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: asy_wondertag (tags-in-tags/tags as attributes)

Any plans to move this logic into crockery? Granted it’ll open a whole can of worms, but it’s usefulness is undeniable. I’ve written many a plugin that this could have solved!

Given that it is “broken by design” and there is hardly a userfirendly way to explain the limitations that the implementation approach has on the usability of this, I doubt it would go into crockery like this. Also the interest in this plugin has been very, very low. It is possible that crockery will have a built-in way that meets the needs in a different way, but the real question is, how far the tag-system is going to be turned into a programming language – it’s a series of delicate trade-offs. I guess all that is jut another way of saying: Not like this, but maybe another way, we’ll see…

Offline

#11 2006-10-31 14:01:34

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: asy_wondertag (tags-in-tags/tags as attributes)

Seems to work with rss_auto_excerpt to get rid of the default permalink title.

comment at rss_auto_excerpt

Edit: I should mention that if you hack the rss_auto_excerpt plugin not to strip all HTML tags (rss_auto_excerpt – keep certain HTML tags) you should create a copy of rss_auto_excerpt. Question: How can somebody (me:) create a working copy of a plugin?

asy_wondertag sounds very interesting. Just didn’t know about it :-)

Last edited by merz1 (2006-10-31 14:26:50)


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#12 2006-10-31 16:18:34

soulship
Member
From: Always Sunny Charleston
Registered: 2004-04-30
Posts: 669
Website

Re: asy_wondertag (tags-in-tags/tags as attributes)

Also the interest in this plugin has been very, very low.

Man, I can’t believe that. I think people just don’t know about it yet, or how thay can use it in a practical way. I am using it a lot, it’s saving me some real headaches here and there.

Offline

Board footer

Powered by FluxBB