Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
Re: RFC: <txp:if_body> tag
Perhaps my idea is overkill after all – thanks, GugUser.
Offline
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
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
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
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
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
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