From e9e0138d3ad7ff6c57d511b758851ebee8631a25 Mon Sep 17 00:00:00 2001 From: molong Date: Sun, 8 Jul 2018 22:04:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=A0=87=E7=AD=BE=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/com/Sent.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/extend/com/Sent.php b/extend/com/Sent.php index d39b3199..d3d65523 100644 --- a/extend/com/Sent.php +++ b/extend/com/Sent.php @@ -25,7 +25,7 @@ class Sent extends Taglib{ // 标签定义 protected $tags = array( // 标签定义: attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次 - 'nav' => array('attr' => 'field,name', 'close' => 1), //获取导航 + 'nav' => array('attr' => 'name,pid', 'close' => 1), //获取导航 'list' => array('attr' => 'table,where,order,limit,id,sql,field,key','level'=>3),//列表 'doc' => array('attr' => 'model,field,limit,id,field,key','level'=>3), 'recom' => array('attr' => 'doc_id,id'), @@ -35,12 +35,11 @@ class Sent extends Taglib{ ); public function tagnav($tag, $content){ - $field = empty($tag['field']) ? 'true' : $tag['field']; - $field = isset($tag['pid']) ? 0 : $tag['pid']; - $tree = isset($tag['tree']) ? true : false; + $pid = isset($tag['pid']) ? 'pid=' . $tag['pid'] : ''; + $tree = isset($tag['tree']) ? $tag['tree'] : 1; $parse = $parse = 'field('.$field.')->where("status=1")->where("pid=1")->order("sort")->select();'; - if($tree){ + $parse .= '$__NAV__ = db(\'Channel\')->where("status=1")->where("'.$pid.'")->order("sort")->select();'; + if($tree == 1){ $parse .= '$__NAV__ = list_to_tree($__NAV__, "id", "pid");'; } $parse .= 'foreach ($__NAV__ as $key => $'.$tag['name'].') {';