9 years ago
2
Topic

http://www.seblod.com/community/forums/fields-plug-ins/images-instead-of-checkbox-radio-box-value

This option seems to show how to create images to replace the checkbox options if they are on the front end.  First, I'm not sure how to implement the solution as it requires each checkbox item has a unique class/id, second, I don't mind the text appearing in the back end, what I want is to change it to an image when it is displayed.

I believe the correct answer is by using typography.  I tried using HTML and entering $cck->getValue('menu_item_allergies'); but nothing appears in the front end.  I also tried a php echo but that was commented out in the front end.  I am happy enough to change my items to item=item.jpg in the backend but that means nothing at all shows.  What I am doing wrong?  Are there any more typography tutorials?

Get a Book for SEBLOD
572 Posts
_jrmo
9 years ago
1
Level 1

Hi there,

If you're using the typography on the checkbox field itself, just use *value* or *text* to get the value or text outputs that were selected.

The difference between text and value, is that you can specify both when you are setting up your checkbox options. In teach option, you can say

text=value

So you could have

Option 1 = item1
Option 2 = item2
Option 3 = item3

Where "Option 1" would be the text (shown on the checkbox label) and "item1" would be the value (stored in the database).

Your problem is going to be that *value* or *text* is going to show a comma delimited list of all the checkboxes selected. So you need to explode these options using a comma as a delimiter in order to add the relevant HTML around each to make them render as images.


So, what you really want is the PHP String typography and use the str_replace option to specify the delimiter (a comma), set what you want to replace all comma's with (probably something like .jpg" /> <img src="/ and then set a prefix and a suffix. Prefix will be <img src=" and suffix will be .jpg" />

Try that, see how you go.


Cheers,

James

154 Posts
WebOne
9 years ago
0
Level 2

Hi,

Thank you for this James.

My solution to add classes to the radio options was to modify the radio field plugin.

Find : plugins/cck_field/radio/radio.php

Seblod 3.72
Line 200 add the following to the input  (change as required)

class="'.$id.$i.' inputclass"

Line 201 add the following to the label (change as required)

class="'.$id.$i.' labelclass"

Get a Book for SEBLOD