哈呢 發表於 2023-8-29 00:00:00

织梦DEDECMS中让近三天发布的文章显示红色日期或加上new字或小图片的方法

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        给近三天(或当天)发布的文章显示红色日期或加上new字或new小<u>图片</u>等。 <br>
        都是围绕pubdate做文章,写扩展的。 <br>
        第2、3要注意的问题是:如:"&lt;img src='new.gif' /&gt;中不能用双引号,否则不行。 <br>
        如果要给当天的加,把 3600 * 24 * 3 改为 3600 * 24  即可。 <br>
        1、==========红色的日期======== <br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode5" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
         <br>
        $a="&lt;font color=red&gt;".strftime('%m-%d',@me)."&lt;/font&gt;"; <br>
        $b=strftime('%m-%d',@me); <br>
        $ntime = time(); <br>
        $day3 = 3600 * 24 * 3; <br>
        if(($ntime - @me) &lt; $day3) @me = $a; <br>
        else @me =$b; <br>
         </div>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>2、==========红色的(new)======== </span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode6" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
         <br>
        $aa=strftime('%m-%d',@me); <br>
        $ntime = time(); <br>
        $tagtime = @me; <br>
        $day3 = 3600 * 24 * 3; <br>
        if($tagtime &gt; $ntime-$day3) @me = "&lt;font color='red'&gt;(new)&lt;/font&gt;"; <br>
        else @me = $aa; <br>
         </div>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>3、==========加new.gif小图片======== </span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode7" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
         <br>
        $aa=strftime('%m-%d',@me); <br>
        $ntime = time(); <br>
        $tagtime = @me; <br>
        $day3 = 3600 * 24 * 3; <br>
        if($tagtime &gt; $ntime-$day3) @me = "&lt;img src='new.gif' /&gt;".$aa; <br>
        else @me = $aa; <br>
         </div>
頁: [1]
查看完整版本: 织梦DEDECMS中让近三天发布的文章显示红色日期或加上new字或小图片的方法