× If you expect answers you should describe your problem and give as much information's as possible. (SQL-Structure, Template Code, Joomla Version ...) Please read this before posting: joodb.feenders.de/support.html

IF function for color change

More
2 years 5 months ago #6335 by kloemi
IF function for color change was created by kloemi
hi together,

I have a column in the database with the type set, which contains three values (administration, drinking water, waste water). Now I want to have a different color depending on what is selected. For two I can do this with ifis and else but how do I do this for three values?

Quasi: Administration = black
Drinking water = blue
Waste water = green

current variant for two color changes:

<dt>Bereichneu2:</dt>
<dd>{joodb ifis|bereich|Bereich Verwaltung|ge} <strong><span style="color: blue;">Bereich Verwaltung</span></strong>
{joodb else|bereich|Bereich Trinkwasser|ge} <strong><span style="color: green;">Bereich Trinkwasser</span></strong>
{joodb endif}</dd>


Thanks for your help

Please Log in to join the conversation.

More
2 years 5 months ago #6336 by Dirk
Replied by Dirk on topic IF function for color change
Joodb else has no parameter.

If you want to do it this way you must open and close 3 ifis condition requests.
Like this. And don't take GE for string compare use EQ.
And remove Bereich from the values in your table.

Instead "Bereich Verwaltung" only "Verwaltung";
<dt>Bereich:</dt>
<dd>
{joodb ifis|bereich|Administration|eq} <strong><span style="color: black;">Bereich Administration</span></strong>{joodb endif}
{joodb ifis|bereich|Verwaltung|eq} <strong><span style="color: blue;">Bereich Verwaltung</span></strong>{joodb endif}
{joodb ifis|bereich|Trinkwasser|eq} <strong><span style="color: green;">Bereich Trinkwasser</span></strong>{joodb endif}
</dd>

But it would be more elegant to define class names (Verwaltung,Trinkwasser and Administration) with the desired colors and add the Field value as class attribute.
<dt>Bereich:</dt>
<dd><strong><span class="{joodb field|bereich}">Bereich {joodb field|bereich}</span></strong></dd>
The following user(s) said Thank You: kloemi

Please Log in to join the conversation.

Moderators: Dirkjoest