Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
sniffing multiple custom fields
Is there a txp native way to check if at least one of the custom fields is populated?
This is what I am trying to achieve
<if populated>
<ul>
<txp:if_custom_field name="one"><li><txp:custom_field name="one'></li></txp:if_custom_field>
<txp:if_custom_field name="two"><li><txp:custom_field name="two'></li></txp:if_custom_field>
etc
</ul>
<txp:else />
</if populated>
Basically if none of the custom fields are populated I don’t want the ul
s to render. Is there a way I can achieve the above?
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: sniffing multiple custom fields
not 100% sure it’ll work, but maybe smd_if ?
~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~
Offline
Re: sniffing multiple custom fields
hi kermie, thanks but I am nevertheless searching for a native way. But since I posted this thread I eventually opted to use chh_if_data so the code becomes
<txp:chh_if_data>
<ul>
<txp:if_custom_field name="one"><li><txp:custom_field name="one' /></li></txp:if_custom_field>
<txp:if_custom_field name="two"><li><txp:custom_field name="two' /></li></txp:if_custom_field>
etc
</ul>
<txp:else />
</txp:chh_if_data>
Which works just fine. I seem to be having time on my hands in the past few days so I am trying to figure out ways to use txp with the minimum of plugins.
>Edit typo
Last edited by colak (2009-04-21 14:56:49)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#4 2009-04-21 14:18:52
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: sniffing multiple custom fields
colak wrote:
Is there a txp native way to check if at least one of the custom fields is populated?
<txp:variable name="whatever" value='<txp:custom_field name="one" /><txp:custum_field name="two" /><etcetera...>' />
<txp:if_variable name="whatever" value="">
<txp:else />
At least one custom field is populated
</txp:if_variable>
Offline
Re: sniffing multiple custom fields
Els to the rescue again. This is embarrassing:) Works beautifully.
I guess the next question would be if anyone know whether the native code works more efficiently to the plugin?
Last edited by colak (2009-04-21 16:24:36)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Pages: 1