jimie VIP
Total posts: 531
21 Apr 2014 07:46

I was wondering if is possible for the select field to be able to set a specific image for each field value:

for example if you want that field to be used fo:

discount display or hotels stars

1 star will use this-image.png 2 stars will use the-other-image.png

and so on

Last Modified: 22 Apr 2014


Sergey
Total posts: 13,748
21 Apr 2014 08:00

I think yes. You can acomplish it in few ways. But here is what I would do.

  1. As values I would insert something like

    STAR1
    STAR2
    STAR3
    STAR4
    STAR5
    
  2. Now in language overrides I would create translation keys.
  3. Now in custom output template of the field I would check $this->value and display image acording to it's value.

jimie VIP
Total posts: 531
22 Apr 2014 07:55

Sergey can you give me an example of if statement for the custome output template to check :

if ($this->value) == 5discount

display 5discount-image.jpg

else

($this->value) == 10discount

display 10discount-image.jpg

and so on..

Would really appriciate :)

rgds


Sergey
Total posts: 13,748
22 Apr 2014 08:25
<img src="/images/discounts/<?php echo $this->value[0]; ?>-image.jpg" alt="<?php echo JText::_($this->value[0]) ?>" />

Place in in custom select field output template. Of corse adjust path to images.


jimie VIP
Total posts: 531
22 Apr 2014 08:42

Simply awesome!!

Respect Sergey !

Powered by Cobalt