css date within today's date

3 weeks 2 hours ago #79660 by tataye
hello,
I have a date field in category ean item view and i'd like to have it red colored when the date is near  (30 days) ( next inspection )
Should we have this feature in the date field ?
For the moment i do not know how to do.
Load it in another field and change value with php ?
change with JS ? ( and how ? )
change with php ? ( and how ? )
I am lost ...
 

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

3 weeks 31 minutes ago - 3 weeks 30 minutes ago #79661 by micker
Replied by micker on topic css date within today's date
hello as i say
we didn't have this feature
i recommand to create a php output
most simple way is
-> put date field in render position
-> edit template field
1 load current time
2 load date field
3 define css variable
3 create an if statement
<?php
$currentdate = YOURCODE;
$datefield =DATEFIELD;
$datecss="";
if ($currentdate > $datefield){
$datecss="red";
}else{
$datecss="green";
}
echo "<span class=".$datecss.">".YOURVALUE."</span>;
?>
that a concept need to check code adding +1month ect

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.

2 weeks 5 days ago #79664 by ggppdk
Replied by ggppdk on topic css date within today's date
Hello

for accessing the value of field inside a template file
please read this

www.flexicontent.org/documentation/tutor...stom-field-type.html


-- 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 review. Thanks!

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

2 weeks 1 hour ago #79668 by tataye
Replied by tataye on topic css date within today's date
so : that is the code that was done and works in template :
<?php  
         $aujourdhui = date();
     $dans_30_jours = date('l d F Y', strtotime($aujourdhui. ' + 30 days')); 
         $dateprochaineinspection = FlexicontentFields::getFieldDisplay($item, 'date-de-la-prochaine-inspection');
 
          if ($dateprochaineinspection > $dans_30_jours){
          $datecss="green";
          }else{
          $datecss="red";
          }
          echo "<span class=\"".$datecss."\">".$dateprochaineinspection."</span>";
?>
Thanks for all ( Micker, ggpdk, and my friend charly)

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

1 week 6 days ago #79669 by micker
Replied by micker on topic css date within today's date
Merci pour le retours !

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.

1 week 6 days ago #79671 by tataye
Replied by tataye on topic css date within today's date
ok
you should before set the field to have the date in good formate
 
and after that ; here is the code that really works :
<?php  
     $aujourdhui = date();
     $dans_30_jours = date('Y-m-d', strtotime($aujourdhui. ' + 30 days'));
     $dateprochaineinspection = FlexicontentFields::getFieldDisplay($item, 'date-de-la-prochaine-inspection');
 
     setlocale(LC_TIME, "fr_FR");
     $dans_30_jours_fr = utf8_encode(strftime("%A %d %B %G", strtotime($dans_30_jours)));
     $dateprochaineinspection_en_fr = utf8_encode(strftime("%A %d %B %G", strtotime($dateprochaineinspection)));
 
     if(strtotime($dateprochaineinspection) > strtotime($dans_30_jours)){
     $datecss="green";
     }else{
     $datecss="red";
     }
     echo "<span class=\"".$datecss."\">".$dateprochaineinspection_en_fr."</span>";
?>


date-de-la-prochaine-inspection should be replaced with the name of your field

and setlocale(LC_TIME, "fr_FR") been set among your lanquage ... 

that is all, I think, thanks to Charly.
 
Attachments:

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

1 week 5 days ago - 1 week 5 days ago #79673 by ggppdk
Replied by ggppdk on topic css date within today's date
instead of getFieldDisplay(), you can also use this
it will give you the raw field value:
$field_id = 444444; // CHANGE to correct field id
$fvals = isset($item->fieldvalues[$field_id]) ? $item->fieldvalues[$field_id] : array();
 
echo '<pre>';
print_r($fvals);
echo '</pre>';


-- 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 review. Thanks!

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

Moderators: vistamediajoomlacornerggppdk
© 2018 Flexicontent. All Rights Reserved.