Print

How to set color have date field regarding visitor date

How to set color have date field regarding visitor date

  • Published by
    serge billon
  • Last modified
    19 January 2021
  • Voting
    Average rating
    2 votes
  • Favourites
  • Tags
  • Concerns
    Plugins Template
  • Since Version
    3.X
  • Up to date
    Yes
  • Profile concerned
    Webdesigner, Developer

if you want to change color regarding ending date

1 create a date field

2 in your item vue edit php and add this whre you want to display it

<?php  

$Now = date();
     
$Date30d = date('Y-m-d', strtotime($Now. ' + 30 days'));
$field_id= XXX, // your flexicontent field idea 
$fvals = isset($item->fieldvalues[$field_id]) ? $item->fieldvalues[$field_id] : array();

        if(strtotime($fvals[0]) > strtotime($Date30d)){      // $fvals[0] for first value in field

            $datecss="green";      
         }else{      
               $datecss="red";    
           }      
         echo "<span class=\"".$datecss."\">".fvals[0]."</span>";
?>




Now you value have class regarding date field , you can set color via css

© 2018 Flexicontent. All Rights Reserved.
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