Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-06-29 20:15:32

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Universal article attribute conditional tag

My question on how to test for article status made me wonder why we have all the various <txp:if_article_xxxxx> conditional tags, which cover only so many different attributes.

Wouldn’t it be more convenient having one tag like this:

<txp:if_article_attribute>

so one could write…

<txp:if_article_attribute status="sticky"> or <txp:if_article_attribute id="12"> etc. ?

Offline

#2 2012-06-29 20:29:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,448
Website GitHub

Re: Universal article attribute conditional tag

masa wrote:

Wouldn’t it be more convenient having one tag like this: <txp:if_article_attribute>

Yeah, or:

<txp:if_attribute type="article" status="sticky">

:-o

With your version it’d probably take some cleverness to get round the lAtts() thing which automatically validates all attributes and complains if one is missing. Although wordier, it might be better as:

<txp:if_article_attribute name="status" value="sticky">

That way, one could omit the value to check for any value at all.

But in essence, it’s probably doable if this kind of thing is broadly useful. Might have to draw the line at certain things, and it won’t make v4.5, but keep discussion alive here and something uber-useful might pop out the other end and appear shortly after in a core near you :-)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2012-06-29 20:47:16

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: Universal article attribute conditional tag

Bloke wrote:

Yeah, or:

<txp:if_attribute type="article" status="sticky">

I like that even better – one conditional tag to rule all types.

Offline

#4 2012-06-30 07:12:13

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

Re: Universal article attribute conditional tag

Bloke wrote:

<txp:if_attribute type="article" status="sticky">

I like it too but I cannot think of any other way the code could be used. ie for files we only have hidden, pending and live and the first two are not intended for the front end.

Would the code below be possible?

<txp:if_attribute type="image" width="74" height="100"><txp:magic /></txp:if_attribute>
or/and
<txp:if_attribute type="thumbnail" width="10" height="10"><txp:magic /></txp:if_attribute>

Last edited by colak (2012-06-30 07:13:27)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB