/* 导航列表 */ public function _nav($tag, $content){ trace($tag); trace($content); trace("end"); $field = empty($tag['field']) ? 'true' : $tag['field']; $tree = empty($tag['tree'])? false : true; $parse = $parse = '<?php '; $parse .= '$__NAV__ = M(\'Channel\')->field('.$field.')->where("status=1")->order("sort")->select();'; if($tree){ $parse .= '$__NAV__ = list_to_tree($__NAV__, "id", "pid", "_");'; } $parse .= '?><volist name="__NAV__" id="'. $tag['name'] .'">'; $parse .= $content; $parse .= '</volist>'; // trace($parse); return $parse; }
맞춤 태그 사용
<think:nav name="nav"> <eq name="nav.pid" value="0"> <li> <a href="{$nav.url|get_nav_url}" target="<eq name='nav.target' value='1'>_blank<else/>_self</eq>">{$nav.title}</a> </li> </eq> </think:nav>