Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

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: 9,007
Website GitHub Mastodon Twitter

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 | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

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

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

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,473

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
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

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: 479
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
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

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
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
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>

Offline

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

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

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,473

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

#11 2014-02-13 14:21:55

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

Re: RFC: <txp:if_body> tag

I guess the advantage of the variable over the other methods is that it only makes one db query.


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

Offline

#12 2014-02-13 15:01:36

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: RFC: <txp:if_body> tag

Maybe open an issue for it at the Google Code project

For consistency, there probably should be a core <txp:if_body> tag.

Offline

Board footer

Powered by FluxBB