详情页

帝国cms的灵动标签和万能标签如何在没有内容时输出“暂无内容”

时间:2023年05月25日

编辑:佚名

帝国cms的灵动标签,如何知道选到了多少条数据呢?
很简单,在灵动标签结尾[/e:loop]后面可以用$bqno来知道选到的数据数。如果没有数据,想显示“暂无内容”,可以用以下代码:
<?php
if($bqno==0)
{
?>
暂无内容
<?php
}
?>
但是对于万能标签,$no变量确暴露不出来,没有办法知道执行的情况。看看代码(/e/class/t_functions.php):
//带模板的标签
function sys_GetEcmsInfo($classid,$line,$strlen,$have_class=0,$enews=0,$tempid,$doing=0,$ewhere='',$eorder=''){
    global $empire,$public_r;
    $sql=sys_ReturnBqQuery($classid,$line,$enews,$doing,$ewhere,$eorder);
    if(!$sql)
    {return "";}
    //取得模板
    $tr=sys_ReturnBqTemp($tempid);
    if(empty($tr['tempid']))
    {return "";}
    $listtemp=str_replace('[!--news.url--]',$public_r[newsurl],$tr[temptext]);
    $subnews=$tr[subnews];
    $listvar=str_replace('[!--news.url--]',$public_r[newsurl],$tr[listvar]);
    $rownum=$tr[rownum];
    $formatdate=$tr[showdate];
    $docode=$tr[docode];
    //替换变量
    $listtemp=ReplaceEcmsinfoClassname($listtemp,$enews,$classid);
    if(empty($rownum))
    {$rownum=1;}
    //字段
    $ret_r=ReturnReplaceListF($tr[modid]);
    //列表
    $list_exp="[!--empirenews.listtemp--]";
    $list_r=explode($list_exp,$listtemp);
    $listtext=$list_r[1];
    $no=1;
    $changerow=1;
    while($r=$empire->fetch($sql))
    {
        $r[oldtitle]=$r[title];
        //替换列表变量
        $repvar=ReplaceListVars($no,$listvar,$subnews,$strlen,$formatdate,$url,$have_class,$r,$ret_r,$docode);
        $listtext=str_replace("<!--list.var".$changerow."-->",$repvar,$listtext);
        $changerow+=1;
        //超过行数
        if($changerow>$rownum)
        {
            $changerow=1;
            $string.=$listtext;
            $listtext=$list_r[1];
        }
        $no++;
    }
    //多余数据
    if($changerow<=$rownum&&$listtext<>$list_r[1])
    {
        $string.=$listtext;
    }
    $string=$list_r[0].$string.$list_r[2];
    echo $string;
}
在//多余数据
后插入一句
 $_POST['jhcno']=$no-1;
则可以这样调用条数:
[ecmsinfo]0,10,32,0,3,2,0,"id='155'"[/ecmsinfo]
《有多少条信息呢?》<?=$_POST['jhcno']?>
相关文章
猜你需要