4414论坛某坛友提到以下要求:
其实是可以用灵动标签解决的,相关代码如下:目前需要在首页调用本站的所有栏目,包括,排序序号递增、栏目名称、栏目缩略图,别名,自定义栏目字段(标红的这2个字段调用不出来),[color=#000]各位大神怎么调用的,有偿!显示结果如下:
[color=#000]1、栏目名称A、栏目缩略图、栏目别名、栏目自定义字段
[color=#000]2、栏目名称B、栏目缩略图、栏目别名、栏目自定义字段
[color=#000]3、栏目名称C、栏目缩略图、栏目别名、栏目自定义字段
[color=#000]...
那如果写成接口的形式那又怎么写呢,以本人二开基础上面写个。写法如下
- [e:loop={"select * from {$dbtbpre}enewsclass where bclassid=0 order by myorder,classid asc",0,24,0}]
- <?php
- $classurl=sys_ReturnBqClassname($bqr,9);//取得栏目地址
- $class="";
- if($GLOBALS['navclassid']) {
- $fcr=explode('|',$class_r[$GLOBALS['navclassid']]['featherclass']);
- $topbclassid=$fcr[1]?$fcr[1]:$GLOBALS['navclassid'];//取得当前栏目的一级栏目ID
- if($bqr[classid]==$topbclassid) {
- $class=" class='on'";
- }
- }
- ?>
- <li<?=$class?>>
- <a href="<?=$classurl?>" class="tit link">大栏目:<?=$bqr['classname']?>(<?=$bqr['intro']?>)</a>
- <div class="menu">子栏目:
- <?php
- $ecms_bq_sql2=sys_ReturnEcmsLoopBq("select * from [!db.pre!]enewsclass where bclassid='$bqr[classid]' order by myorder limit 10",20,24,0);
- $bqno2=0;
- while($bqr2=$empire->fetch($ecms_bq_sql2)) {
- $bqsr2=sys_ReturnEcmsLoopStext($bqr2);
- $bqno2++;
- ?>
- <a href="/<?=$bqr2['classpath']?>/"><?=$bqr2['classname']?></a>
- <?php
- }
- ?>
- </div>
- </li>
- [/e:loop]
- // 获取顶级类别信息
- $list = $api->load('db')->select('[!db.pre!]enewsclass', 'bclassid,classid,classname,classpagekey,intro,tbname', 'bclassid='.$bclassid.' and classid not in(100,133,180,188,216)', 'showclass='.$showclass, 'myorder DESC');
- $result = [];// 初始化结果数组
- // 获取所有子类别信息
- foreach ($list as $top) {
- $son = $class_r[$top['classid']]['sonclass'];
- $sonarr = explode("|", $son);
- array_shift($sonarr);
- array_pop($sonarr);
- $classtr = implode(",", $sonarr);
- if ($classtr) {
- $sonclass_sql = "classid in (" . $classtr . ")";
- $lists = fetch_memcache0("select * from {$dbtbpre}enewsclass where $sonclass_sql", 'Memcached', 'alltype', 3600 * 24 * 30);
- $topData = [
- 'topclassid' => $top['classid'],
- 'topclassname' => $top['classname'],
- 'topmid' => $class_r[$top['classid']]['modid'],
- 'topclasspagekey' => $top['classpagekey'],
- 'topintro' => $top['intro'],
- 'sonclassid' => [],
- 'sonclassname' => [],
- 'sonclasspath' => [],
- 'sonintro' => [],
- 'sonmid' => []
- ];
- foreach ($lists as $class) {
- $topData['sonclassid'][] = $class['classid'];
- $topData['sonclassname'][] = $class['classname'];
- $topData['sonmid'][] = $class_r[$class['classid']]['modid'];
- $topData['sonclasspath'][] = $class['classpath'];
- $topData['sonintro'][] = $class['intro'];
- }
- $result[] = $topData; // 将顶级类别信息添加到结果数组
- } else {
- $result[] = [
- 'topclassid' => $top['classid'],
- 'topclassname' => $top['classname'],
- 'topmid' => $class_r[$top['classid']]['modid'],
- 'topclasspagekey' => $top['classpagekey'],
- 'topintro' => $top['intro'],
- 'sonclassid' => [],
- 'sonclassname' => [],
- 'sonclasspath' => [],
- 'sonintro' => [],
- 'sonmid' => []
- ];
- }
- }
- $output = [
- 'code' => 1,
- 'list' => $result,
- ];
- // 输出json数据
- $api->json($output);