PHP实现帝国cms全部栏目板块调用

帝国cms标签虽然很强大,但是对于多层嵌套写法看着很晕,我还是喜欢用PHP代码来实现,采用PHP代码写法灵活性更好,这里涉及到2个函数知识点在次记录下,


sys_ReturnBqClassname($r0,9)返回栏目链接地址支持静态链接地址,其中$r0是当前栏目表数据

sys_ReturnBqTitleLink($r1)返回标题链接(静态)链接地址,其中$r1是当前信息表数据

具体使用参考如下代码

<?php
$style=array('g-beiyun','g-problem','g-makeup','','g-mother');
$sqllm=$empire->query("select * from {$dbtbpre}enewsclass where bclassid=0 order by myorder,classid asc limit 0,2");
$ks=0;
while($r=$empire->fetch($sqllm))
{
    ?>
<section class="g-white-box g-index-health <?php if(isset($style[$ks])){echo $style[$ks];}else{$ks=0;echo $style[$ks];}$ks++;?>">
    <strong class="g-title"><b><?=$r['classname']?><i></i></b><em></em></strong>
    <div class="g-list-nav">
        <div class="g-list-nav plist" id="g-health-nav">
            <ul class="g-list-nav-ul">
                <?php

                $sql0=$empire->query("select * from {$dbtbpre}enewsclass where bclassid={$r['classid']} order by myorder,classid");
                $list=array();
                while($r0=$empire->fetch($sql0))
                {
                    $list[]=$r0['classid'];
                ?>
                <li><a href="<?=sys_ReturnBqClassname($r0,9)?>"><?=$r0['classname']?></a></li>
               <?php } ?>
            </ul>
        </div>
        <i></i>
    </div>
    <dl class="g-health-recomd">


        <?php
        $tbname=$class_r[$r['classid']]['tbname'];
        $sonclass=str_replace('|',',',trim($r['sonclass'],'|'));
        $r1=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where classid in(".$sonclass.") and isgood=1 and titlepic != '' order by newstime desc limit 0,1");
        $showedid=$r['id'];
        $whereshowid='';
        if($r1){
        ?>
        <dt>            <a href="<?=sys_ReturnBqTitleLink($r1)?>"><img alt="<?=$r1['title']?>" src="<?=$r1['titlepic']?>"></a>
        </dt>
        <dd>            <a href="<?=sys_ReturnBqTitleLink($r1)?>"><?=$r1['title']?></a>            <p><?=esub($r1['smalltext'],120)?>……</p>        </dd>
    <?php  } ?>
    </dl>

    <ul class="g-health-ul">
        <?php
        if($showedid)$whereshowid=" and id not in($showedid)";
        $sql=$empire->query("select * from {$dbtbpre}ecms_".$tbname." where classid in({$sonclass}) {$whereshowid} order by newstime desc limit 1,4");
        $ko=0;
        while($r2=$empire->fetch($sql))
        {
            $ko++;
        ?>
        <li><b><?=$ko?></b><a href="<?=sys_ReturnBqTitleLink($r2)?>"><?=$r2['title']?></a></li>
        <?php } ?>
    </ul>
    <a href="<?=sys_ReturnBqClassname($r,9)?>" class="g-health-more"><span>查看更多 ></span></a>
</section>
<?php } ?>

最终展示效果image.png

支付宝扫码打赏 微信扫码打赏

如果本文对你有帮助,欢迎打赏本站

喜欢 ()or分享
    匿名评论
  • 评论
人参与,条评论