优化标签,增加模型标签的使用demo

This commit is contained in:
2020-04-26 22:10:30 +08:00
parent dc279c9fad
commit 1a2fbeddd2
2 changed files with 5 additions and 2 deletions

View File

@@ -37,7 +37,7 @@ class Sent extends \think\template\TagLib {
public function tagdoc($tag, $content){ public function tagdoc($tag, $content){
$model = !empty($tag['model']) ? $tag['model']:''; $model = !empty($tag['model']) ? $tag['model']:'';
$cid = isset($tag['cid']) ? (int) $tag['cid'] : 20; $cid = isset($tag['cid']) ? (int) $tag['cid'] : 0;
$field = empty($tag['field']) ? '*' : $tag['field']; $field = empty($tag['field']) ? '*' : $tag['field'];
$limit = isset($tag['limit']) ? (int) $tag['limit'] : 20; $limit = isset($tag['limit']) ? (int) $tag['limit'] : 20;
$order = empty($tag['order']) ? 'id desc' : $tag['order']; $order = empty($tag['order']) ? 'id desc' : $tag['order'];
@@ -45,7 +45,7 @@ class Sent extends \think\template\TagLib {
$parse = $parse = '<?php '; $parse = $parse = '<?php ';
$parse .= '$__LIST__ = \\app\\model\\Document::getDocumentList("'.$model.'", '.$cid.', '.$limit.', "'.$order.'", "'.$field.'");'; $parse .= '$__LIST__ = \\app\\model\\Document::getDocumentList("'.$model.'", '.$cid.', '.$limit.', "'.$order.'", "'.$field.'");';
$parse .= 'foreach ($__LIST__ as $key => $'.$tag['name'].') {'; $parse .= 'foreach ($__LIST__ as $key => $'.$name.') {';
$parse .= '?>'; $parse .= '?>';
$parse .= $content; $parse .= $content;
$parse .= '<?php } ?>'; $parse .= '<?php } ?>';

View File

@@ -30,6 +30,9 @@ html, body {background-color: #fff; color: #636b6f; font-family: 'Raleway', sans
{sent:nav tree="false" type="1" name="item"} {sent:nav tree="false" type="1" name="item"}
<li><a href="{$item['url']}">{$item['title']}</a></li> <li><a href="{$item['url']}">{$item['title']}</a></li>
{/sent:nav} {/sent:nav}
{sent:doc model="article" limit="10" cid="1"}
<li><a href="{:url('/article/detail-'.$item['id'])}">{$item['title']}</a></li>
{/sent:doc}
<div class="flex-center position-ref full-height"> <div class="flex-center position-ref full-height">
<div class="content"> <div class="content">
<div class="title m-b-md"> <div class="title m-b-md">