IF $class = ($value->status == "done") HOW? |
Guys, I would like to use this to show three different colors on my gantt chart:
Code: $class = ($value->status == "done") ? "#336699" : ""; Currently I have one color, that shows done tasks Is this possible to use something like: Code: if $class = ($value->status == "open") ? "#536699" : ""; But of course above code doesn't work. Can You please help me to create some "if" listing for that?
I would propose another way. Make the following helper function, PHP:
Code: function get_task_status_class($status) { It is to be used within the views, for example: Code: <span class="task-name <?php echo get_task_status_class($status); ?>"><?php echo html_escape($task_name); ?></span> And add to your CSS: Code: .task-name.open {
You can use the switch conditional statement:
PHP Code: switch ($value->status) {
Hello,
Why not that : $class = ($value->status == 'open') ? "#536699" : (($value->status == 'in_progress') ? "#796699" : (($value->status == 'done') ? "#336699" : "")); Matt.
This will also work.
PHP Code: if($value->status === "open") I think that @ivantcholakov suggestion of using a CSS file instead of hardcoded color values is a very good idea. Not that I set a good example of that here |
Welcome Guest, Not a member yet? Register Sign In |