• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Change row background color with condition tricks.

myfatebiz

Active Member
Hi all,

I just wanna share how i figure out according my title. All just need change default_row.php on your list template.

1. Create new date element.
2. Open your default_row.php

Code:
<?php
/**
* Fabrik List Template: Default Row
*
* @package    Joomla
* @subpackage  Fabrik
* @copyright  Copyright (C) 2005 Fabrik. All rights reserved.
* @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
 
// No direct access
defined('_JEXEC') or die;
?>
<tr id="<?php echo $this->_row->id;?>" class="<?php echo $this->_row->class;?>">
    <?php foreach ($this->headings as $heading => $label) {
        $style = empty($this->cellClass[$heading]['style']) ? '' : 'style="'.$this->cellClass[$heading]['style'].'"';
        ?>
        <td class="<?php echo $this->cellClass[$heading]['class']?>" <?php echo $style?>>
            <?php echo @$this->_row->data->$heading;?>
        </td>
    <?php }?>
</tr>

Change to

Code:
<?php
/**
* Fabrik List Template: Default Row
*
* @package    Joomla
* @subpackage  Fabrik
* @copyright  Copyright (C) 2005 Fabrik. All rights reserved.
* @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
 
// No direct access
defined('_JEXEC') or die;
?>
 
<?php
 
$date= $this->_row->data->youtablename___date_raw;
$date = strtotime($date);
$now = time();
$diff = $now - $date;
$years = floor($diff / 31556926);
 
?>
 
<!-- Color 1 -->
<?php IF ($years <= 10) { ?>
<tr style="background-color:#FFFF99" id="<?php echo $this->_row->id;?>" class="<?php echo $this->_row->class;?>">
    <?php foreach ($this->headings as $heading => $label) {
        $style = empty($this->cellClass[$heading]['style']) ? '' : 'style="'.$this->cellClass[$heading]['style'].'"';
        ?>
        <td class="<?php echo $this->cellClass[$heading]['class']?>" <?php echo $style?>>
            <?php echo @$this->_row->data->$heading;?>
        </td>
    <?php }} ?>
</tr>
<!-- Color 2 -->
<?php IF ($years > 11 && $years < 30) { ?>
<tr style="background-color:#C0C0C0" id="<?php echo $this->_row->id;?>" class="<?php echo $this->_row->class;?>">
    <?php foreach ($this->headings as $heading => $label) {
        $style = empty($this->cellClass[$heading]['style']) ? '' : 'style="'.$this->cellClass[$heading]['style'].'"';
        ?>
        <td class="<?php echo $this->cellClass[$heading]['class']?>" <?php echo $style?>>
            <?php echo @$this->_row->data->$heading;?>
        </td>
    <?php }} ?>
</tr>
<!-- Color 3 -->
<?php IF ($years > 30) { ?>
<tr style="background-color:#00FFFF" id="<?php echo $this->_row->id;?>" class="<?php echo $this->_row->class;?>">
    <?php foreach ($this->headings as $heading => $label) {
        $style = empty($this->cellClass[$heading]['style']) ? '' : 'style="'.$this->cellClass[$heading]['style'].'"';
        ?>
        <td class="<?php echo $this->cellClass[$heading]['class']?>" <?php echo $style?>>
            <?php echo @$this->_row->data->$heading;?>
        </td>
    <?php }} ?>
</tr>

Insert new record with different year on the date and the background color on the row will be change base on condition above. This also can be use on cell if you know how to figure out.

Best Regards,
MyFateBiz
 
Thanks so much
I try to have a warning message (cell color or incon warning) in list view in the case the date is exipred.
Can you help me?
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top