偶是初学php模板技术,现遇到难题一个:希望各位大虾不吝赐教!
部分源码如下:模板文件源码:
功能:调用公司列表。需要实现其中的{new}用来显示如果该公司有最近3天发布的文章,则显示一个提示图标。          <!-- BEGIN sjListIndex -->
          <tr>
            <td width="108" height="26" align="center" bgcolor="#FFFFFF"><a href="{appPath}/vipweb/?nameID={userName}" target="_blank">{corpName}</a> {new}</td>
            <td width="60" align="center" bgcolor="#F9F9F9">{catPath}</td>
            <td width="79" align="center" bgcolor="#FFFFFF">{corpStatus}</td>
            <td align="left" bgcolor="#F9F9F9">&nbsp;{corpAddress}</td>
            <td align="center" bgcolor="#FFFFFF">&nbsp;{corpTel}</td>
          </tr>
          <!-- END sjListIndex -->处理页main.php(主要部分 代码)功能:经模板变量赋值$sjListIndex = $art->_list_index(($condition['page']-1)*$condition['rows'],$condition['rows']);
foreach($sjListIndex as $key => $row)
{
$sjListIndex[$key]['new']="<font color=red>new</font>";
if($sjListIndex[$key]['catPath']=="0,1" || $sjListIndex[$key]['catPath']=="0,1,32")
{
$sjListIndex[$key]['catPath']="私营";
}
elseif ($sjListIndex[$key]['catPath']=="0,1,33")
{
$sjListIndex[$key]['catPath']="国营";
}
if($sjListIndex[$key]['corpStatus']=="0")
{
$sjListIndex[$key]['corpStatus']="正常营业";
}
elseif ($sjListIndex[$key]['corpStatus']=="1")
{
$sjListIndex[$key]['corpStatus']="暂停营业";
}

} $this->tpl->assign('sjListIndex',$sjListIndex );
商家数据库表(sj)字段:
id, userName, corpName, corpUnionarea, catPath, province, city, corpMan, corpTel, corpEmail, corpAddress, corpInfo, corpStatus, corpClass, recommend, audit, lastLogintime, registertime, hitnums商家文章数据库表(sjarticle)字段
id, title, summary, postTime, author, comeFrom, content, keyword, catPath, isImg, linkPath, audit, recommend, hitnums, isBreakingNews, logo, corpuserNamesj.userName==sjarticle.corpuserName 靠这两个关联。Thank you so much!

解决方案 »

  1.   


    需要 实现 其中的{new}用来显示如果该对应的公司有最近3天发布的文章,则显示一个new提示图标。来表示该公司有新的资讯。
      

  2.   

    $sjListIndex[$key]['new']=" <font color=red>new </font>"; --$sjListIndex[$key]['new']= 是否是三天内发的 ? "<img src='新'>" : ""; 
      

  3.   


    感谢你的回答不过要注意的是:
    {new}的值的结果要从 商家文章数据库表中的postTime字段然后经过日期运算(即当前日期减去postTime),如果<=3,{new}值则输出为新资讯图标。问题就是如何将sjarticle表中的postTime字段传到$sjListIndex数组中进行断判??
      

  4.   


     $b="2009-08-21"; //新闻发布的时间
     $today=date('Y-m-d',time());//现在的时间
     echo strtotime($today)-strtotime($b)==0?"new":"";//如果是今天发布的 则显示new 否则什么都不显示
      

  5.   

    搞了一下
    你测试下 是不是你要的效果? $b="2009-08-22"; //新闻发布的时间
     $today=date('Y-m-d',time());//现在的时间
     $d=strtotime($today)-strtotime($b); //得到时间差
     $f=round($d/3600/24);//算出差几天
     echo $f<=3?"new":""; //你要的效果 如果是三天内的呢 出现new
      

  6.   


    问题就是$b="2009-08-22";(文档日期)如何从sjarticle表获取出来呢??