Background color in function of the field's value

More
6 years 2 weeks ago - 6 years 2 weeks ago #72259 by erica
hello,
I want to change a background-color of a field (in frontend view) function of the value of the field.
eg : if value == 1 background : green else background : red;
How i can make this ?
I searched in forum but without result
Last edit: 6 years 2 weeks ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
6 years 2 weeks ago #72260 by ggppdk
Hello

it is easy you can
- duplicate the default layout file of the field, modify it
- then select it in field configuration

e.g. for "text" field
duplicate
Code:
plugins\flexicontent_fields\text\tmpl\value_default.php
as
Code:
plugins\flexicontent_fields\text\tmpl\value_mycoloredlayout.php


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
6 years 2 weeks ago #72261 by micker
or just working in template view (need to adapte on categorie view or item view)
Code:
<?php $backclass=""; if($item->field['tonchamps'] == 1{ $backclass="Toncodecouleurrouge"; } else { $backclass="Toncodecouleurvert"; } ?> <div class="<?php echo $backclass; ?>" ....

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

More
6 years 2 weeks ago #72262 by erica
Micker,

I prefere work with template view.
Where I write this code : file "item.php" (for the item view) ?

Please Log in or Create an account to join the conversation.

More
6 years 2 weeks ago #72263 by ggppdk
Hello

if you do it with the custom field layout
then it will work everywhere

item view
category view
modules


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
6 years 2 weeks ago #72264 by erica
Ok I anderstand.
I don't arrived to writte the good code in order to customise the background.
Could you explain more ?

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.289 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline