Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-02-13 10:10:33

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,482

RFC: <txp:if_body> tag

Most components of the article have if_ conditionals, but I don’t see one for if_body. The body isn’t mandatory, and while it’s arguable that an article should have body content, that’s not always the case.

I’m thinking out loud; what do you think? Overkill?

Edited title x3 to reflect workarounds/solutions provided/discussion

Last edited by gaekwad (2014-02-14 11:14:49)

Offline

#2 2014-02-13 10:14:17

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,246
Website

Re: RFC: <txp:if_body> tag

With the variable tag all if tags could become obsolete.

<txp:variable name="ifbody" value='<txp:body />' />
<txp:if variable name="ifbody" value="">
no body
<txp:else />
<txp:variable name="ifbody" />
</txp:if_variable>

Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | Respbublika! | NeMe @ github

Offline

#3 2014-02-13 10:15:55

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,482

Re: RFC: <txp:if_body> tag

Oh, smart!

Offline

#4 2014-02-13 11:01:45

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,400

Re: RFC: <txp:if_body> tag

Also works:

<txp:if_custom_field name="body">
	(…)
</txp:if_custom_field>

Offline

#5 2014-02-13 11:03:35

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,482

Re: RFC: <txp:if_body> tag

Perhaps my idea is overkill after all – thanks, GugUser.

Offline

#6 2014-02-13 11:05:02

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 478
Website

Re: RFC: <txp:if_body> tag

I use that

<txp:if_custom_field name="body">
Body
<txp:else />
No Body
</txp:if_custom_field>

Edit : Too late !

Last edited by sacripant (2014-02-13 11:06:14)

Offline

#7 2014-02-13 11:07:03

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,482

Re: RFC: <txp:if_body> tag

I like the fewer-tags-in-core idea, having thought about it a little longer – especially with <txp:if_custom_field name="body">. Good advice – thanks to you all.

Offline

#8 2014-02-13 12:23:47

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,193
Website

Re: RFC: <txp:if_body> tag

Maybe I’m missing something, but why fake the if at all? Just don’t declare a body.

<txp:article>
   <txp:title />
   <txp:exerpt />
</txp:article>

Want a single instance of output? Point to the ID.

<txp:article_custom id="">
   <txp:exerpt />
</txp:article_custom>

The text persuades, the *notes prove。

Offline

#9 2014-02-13 12:27:20

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,482

Re: RFC: <txp:if_body> tag

Hi Destry – you’re not missing anything at all. The reason for my asking is for a site I’m working on that may have a body or may not, and I wanted to cover all the bases. I’m working on the principle that the more I can bake into the code at this stage, the less stuff I have to remember when I’m making content for the site, hence the idea of if_body.

Offline

#10 2014-02-13 14:03:11

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,400

Re: RFC: <txp:if_body> tag

Destry wrote #278911:

Maybe I’m missing something, but why fake the if at all? Just don’t declare a body.

It can be helpful in the case when you want some more tags or code if the body has content.

Offline

Board footer

Powered by FluxBB