Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-07-03 17:05:49

beechy
Member
Registered: 2006-03-02
Posts: 92

Conditional statement help

I want to do the following I imagine it is really simple but I dont have a clue on the conditional statement logic can anyone help please

<txp:if_custom_field name=“image_caption”>
<txp:custom_field name=“image_caption” />

<txp:if_custom_field name=“image_caption_2”>
<txp:custom_field name=“image_caption_2” />

<txp:else />
Dont display anything

Offline

#2 2008-07-03 17:19:39

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Conditional statement help

If you really don’t want to display anything for the else case, the below will be sufficient:

<txp:custom_field name="image_caption" />
<txp:custom_field name="image_caption_2" />

Edit: Removed even more superfluous stuff

Last edited by uli (2008-07-03 18:00:48)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2008-07-03 17:22:58

beechy
Member
Registered: 2006-03-02
Posts: 92

Re: Conditional statement help

Sorry my mistake I do want to display something different for the else case – ie

<txp:if_custom_field name=“image_caption”>
<txp:custom_field name=“image_caption” />

<txp:if_custom_field name=“image_caption_2”>
<txp:custom_field name=“image_caption_2” />

<txp:else />
Display some html here

Offline

#4 2008-07-03 17:28:33

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Conditional statement help

<txp:chh_if_data>
	<txp:custom_field name="image_caption" />
	<txp:custom_field name="image_caption_2" />
<txp:else />
Your HTML goes here.
</txp:chh_if_data>

chh_if_data is a plugin.

Edit: Superfluous stuff removed

Last edited by uli (2008-07-03 18:02:27)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#5 2008-07-03 17:31:48

beechy
Member
Registered: 2006-03-02
Posts: 92

Re: Conditional statement help

Many thanks will try it out

Offline

#6 2008-07-03 18:09:44

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Conditional statement help

In casee you’ve copied my code already: delete it and use the corrected version above. D’oh, so much nonsense by copying/pasting! =/


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB