帝国列表内容模板(list.var) 随机图片,判断推荐、头条、置顶等复杂调用

随机图片
$rand=rand(1,50);
if($r[titlepic]){
$listpic='[!--titlepic--]';
}else{
$listpic='/themes/images/'.$rand.'.jpg';
}
判断推

随机图片

w5UECMSPLUS
$rand=rand(1,50);w5UECMSPLUS
 if($r[titlepic]){w5UECMSPLUS
 $listpic='[!--titlepic--]';w5UECMSPLUS
 }else{w5UECMSPLUS
 $listpic='/themes/images/'.$rand.'.jpg';w5UECMSPLUS
 }w5UECMSPLUS
 w5UECMSPLUS

判断推荐、头条、置顶,并加(推荐、头条、置顶图)显示

w5UECMSPLUS
$newimg="";w5UECMSPLUS
if($r[istop]==1)w5UECMSPLUS
{w5UECMSPLUS
$newimg="<font color=red>[顶]</font>";w5UECMSPLUS
}w5UECMSPLUS
elseif($r[isgood]==1)  w5UECMSPLUS
{w5UECMSPLUS
$newimg="<font color=red>[荐]</font>";w5UECMSPLUS
}w5UECMSPLUS
elseif($r[firsttitle]==1)  w5UECMSPLUS
{w5UECMSPLUS
$newimg="<font color=red>[头]</font>";w5UECMSPLUS
}w5UECMSPLUS

列表内容模板(list.var) (*) 示例

$listtemp='<li class="items-li j-items-li "> <a href="[!--titleurl--]" target="_blank" style="position:relative;"> <img class="goodsimg" data-original="'.$listpic.'" src="'.$listpic.'" alt="[!--title--]" /> </a>w5UECMSPLUS
  <div class="wrap_div">w5UECMSPLUS
<span class="description"> '.$newimg.' <a href="[!--this.classlink--]" target="_blank" title="[!--this.classname--]"><i class="dot2"></i> [!--this.classname--]</a> </span>w5UECMSPLUS
    <div> <b class="title"><a href="[!--titleurl--]" title="[!--title--]" target="_blank">[!--title--]</a></b>w5UECMSPLUS
      <p class="price-attente">立即购买</p>w5UECMSPLUS
    </div>w5UECMSPLUS
  </div>w5UECMSPLUS
  <p class="price-attente">  <span class="time">'.user_time($r[newstime],0).'</span> <span class="price"> ¥[!--price--]元 </span> <span class="attente" title="浏览量">[!--onclick--]</span> </p>w5UECMSPLUS
</li>';w5UECMSPLUS

 

【帝国CMS】时间格式改成几分钟,几小时,几天前

w5UECMSPLUS
然后在帝国cms模版里放入相应的时间标签。w5UECMSPLUS
w5UECMSPLUS
1、在标签模板、列表模板中的调用:'.user_time($r[newstime],0).'w5UECMSPLUS
w5UECMSPLUS
2、在内容页中调用:<?=user_time($navinfor[newstime],0)?>w5UECMSPLUS
w5UECMSPLUS
把以下的内容复制到 /e/class/userfun.php 文件里,放在<?php和?>之间就可以了。w5UECMSPLUS
 

如下示例代码:

function user_time($tm, $num) {
    if ($num == 1) {
        $tm = strtotime($tm);
    }
    $cur_tm = time();
    $dif = $cur_tm - $tm;
    $pds = array(&#039;秒&#039;, &#039;分钟&#039;, &#039;小时&#039;, &#039;天&#039;, &#039;周&#039;, &#039;个月&#039;, &#039;年&#039;);
    $lngh = array(1, 60, 3600, 86400, 604800, 2630880, 31570560);
    for ($v = sizeof($lngh) - 1; ($v &gt;= 0) && (($no = $dif / $lngh[$v]) &lt;= 1); $v--);
    if ($v &lt; 0) $v = 0;
    $_tm = $cur_tm - ($dif % $lngh[$v]);
    $no = floor($no);
    $x = sprintf(&quot;%d%s&quot;, $no, $pds[$v]);
    return $x.&quot;前&quot;;
}
分享到 :
相关推荐

发表评论

登录... 后才能评论

评论(3)

加入本站VIP会员订阅计划,海量资源免费下载查看

目前为止共有3位优秀的VIP会员加入!

立即加入VIP会员