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!

Post reply

Can't comment until