How can DEDECMS modify the newly published content to display red within 24 hours, and change it to the common set color after more than 24 hours? We all know that the newly published call tag is in the homepage template of the template directory. We open templates/default/index.htm. Let's assume that the following code is the latest published tag of the site:
Latest publication
{dede:arclist titlelen='60' noflag='h' row='13'}
[field:pubdate function="MyDate('m-d',@me)"/][field:title/]
{/dede:arclist}
The following code is the red call tag within 24 hours after our modification:
Latest publication
{dede:arclist titlelen='60' noflag='h' row='13'}
[field:pubdate runphp='yes'] $a=""; $ d=""; $ b=""; $ c=strftime("%m-%d","@me"); $ ntime = time(); $ oneday = 3600 * 24; if(($ntime - @me)<$oneday) @me = $a.$c.$b; else @me = $d.$c.$b; [/field:pubdate] [field:title/]
{/dede:arclist}
This is OK. Many people will not use the default template of DEDECMS, so I call the latest tag here differently from yours. If you use the default template on your home page, you only need to change the following code:
[field:pubdate function="MyDate('m-d',@me)"/]
Replace with the following code:
[field:pubdate runphp='yes']
$a="";
$d="";
$b="";
$c=strftime("%m-%d","@me");
$ntime = time();
$oneday = 3600 * 24;
if(($ntime - @me)<$oneday) @me = $a.$c.$b;
else @me = $d.$c.$b;
[/field:pubdate]
That's it!
Statement: All articles on this site, unless otherwise specified or marked, are originally published on this site. No individual or organization is allowed to copy, embezzle, collect and publish the content of this website to any website, book and other media platforms without the consent of this website. If the content of this website infringes upon the legitimate rights and interests of the original author, please contact us for handling.