Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2012-09-14 16:54:20
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
<txp:if_custom_field> Checkbox Assistance
Currently, I have a site where I want to display different images based on what has been identified in the custom fields. I am using Gerhard’s Plug in for the custom fields.
For Selection Fields and Text Boxes there is no problem. My issue is with Checkboxes. I need to be able to say … if California is checked display this image and if Ohio is checked display this image —- I tried running the standard below
<txp:if_custom_field name="state" value="California">
<img src="/images/icons/CA.jpg" />
</txp:if_custom_field>
But it does not return any results.
Any guidance would eb greatly appreciated.
progre55
Offline
#2 2012-09-14 19:59:54
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: <txp:if_custom_field> Checkbox Assistance
The tags look OK to me, no forbidden TXP value field named state I know of.
For states (or generally: more than one field where only one value should be chosen) you’d probably better use radios: two checkboxes, inadvertently ticked, cause a pipe character in the DB field that breaks your if_cf logic. Have you checked your DB for character remainders in that cf? Is the image accessible under the path you’ve entered?
Last edited by uli (2012-09-14 20:02:53)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#3 2012-09-14 20:03:17
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
Re: <txp:if_custom_field> Checkbox Assistance
Uli:
Maybe I was not clear. I want a checkbox because an article can have multiple “states” checked. Depending on what is checked the corresponding images will display. I have checked and the above tags work if only it is a select or text field. So I know it can easily access the images. There is something with the checkbox that is not allowing the image to display using the above code.
progre55
Offline
#4 2012-09-14 20:10:59
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: <txp:if_custom_field> Checkbox Assistance
progre55 wrote:
There is something with the checkbox that is not allowing the image to display using the above code.
From my own experiences it was that said pipe character that checkboxes enter for multiple selections.
And it made necessary I used match="any"
.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#5 2012-09-14 20:13:40
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: <txp:if_custom_field> Checkbox Assistance
any
requires the values to be unique, BTW, like men
is not unique enough when women
is part of the list.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#6 2012-09-14 20:32:32
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
Re: <txp:if_custom_field> Checkbox Assistance
Uli:
What if I do not want any, but a specific value. When I I run it now, “match” works — in terms of pulling up an image —- but if any check box is ticked it pulls up the picture — even if the check box for that picture is not selected.
progre55
Offline
#7 2012-09-14 21:10:21
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: <txp:if_custom_field> Checkbox Assistance
You’re using this code here, right?
<txp:if_custom_field name="state" value="California" match="any">
<img src="/images/icons/CA.jpg" />
</txp:if_custom_field>
You’re not using tags in tags, you’ve ticked Ohio and nothing else, you’ve checked the contents of your cf in the DB, circumvented cacheing issues when looking at the DB and the article in question, up comes California: I’ve no idea ATM, sorry.
Edited to add the missing blank in the code.
Last edited by uli (2012-09-14 21:15:48)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#8 2012-09-14 21:17:39
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
Re: <txp:if_custom_field> Checkbox Assistance
Uli:
My bad. I had written the code incorrectly. Using your code, returns exactly what I am looking for. Thank you for your assistance.
progre55
Last edited by progre55 (2012-09-14 21:17:54)
Offline