循环数据调用演示1
通过模板标签volist循环显示控制器已查询定义的数据列表。
  • 3263-DaiCuo验证码--https://demo.daicuo.org/example/nav/detail?id=3263
  • 3262-DaiCuo表单--https://demo.daicuo.org/example/nav/detail?id=3262
  • 3261-DaiCuo表格--https://demo.daicuo.org/example/nav/detail?id=3261
  • 3260-DaiCuo菜单--https://demo.daicuo.org/example/nav/detail?id=3260
  • 3259-DaiCuo标签--https://demo.daicuo.org/example/nav/detail?id=3259
  • 3258-DaiCuo分类--https://demo.daicuo.org/example/nav/detail?id=3258
循环数据调用演示2
通过在模板里使用助手函数(DcTermNavbar)调用栏目分类循环数据。
  • 3258-DaiCuo分类--https://demo.daicuo.org/example/nav/detail?id=3258
  • 3259-DaiCuo标签--https://demo.daicuo.org/example/nav/detail?id=3259
  • 3260-DaiCuo菜单--https://demo.daicuo.org/example/nav/detail?id=3260
  • 3261-DaiCuo表格--https://demo.daicuo.org/example/nav/detail?id=3261
  • 3262-DaiCuo表单--https://demo.daicuo.org/example/nav/detail?id=3262
  • 3263-DaiCuo验证码--https://demo.daicuo.org/example/nav/detail?id=3263
控制器源码(apps/example/controller/Navs.php) 复制
<?php
namespace app\example\controller;

use 
app\common\controller\Front;

class 
Navs extends Front
{
    public function 
_initialize()
    {
        
parent::_initialize();
    }
    
    public function 
index()
    {   
        
//查询数据
        
$list model('common/Navs','loglic')->select([
            
'cache'  => false,
            
'result' => 'array',//tree|array
            
'module' => 'example',
            
'type'   => 'link',//navbar|sitebar|nav|bottom|link|ico|image|other
            
'limit'  => 10,
            
'page'   => false,
            
'sort'   => 'term_id',
            
'order'  => 'desc',
        ]);
        
//变量定义
        
$this->assign('data',$list);
        
//加载模板
        
return $this->fetch();
    }
}
模板源码(apps/example/theme/default/nasv/index.tpl) 复制
{extend name="apps/common/view/front.tpl" /}
<!--meta-->
{block name="header_meta"}
<title>DaiCuo菜单组件调用实例-{:config('common.site_name')}</title>
<meta name="keywords" content="DaiCuo标签组件" />
<meta name="description" content="呆错后台管理框架菜单组件数据调用开发实例。" />
{/block}
<!--header-->
{block name="header"}
  {include file="apps/common/view/widget/header.tpl" /}
{/block}
<!--main-->
{block name="main"}
<div class="container pt-2">
  <div class="card mb-3">
    <div class="card-header font-weight-bold">循环数据调用演示1</div>
    <div class="card-body">
      <blockquote>通过模板标签volist循环显示控制器已查询定义的数据列表。</blockquote>
      <ul class="card-text">
        {volist name="data" id="nav"}
        <li>{$nav.navs_id}-{$nav.navs_name}-{$nav.navs_slug}-{:DcUrl('example/nav/detail',['id'=>$nav['navs_id']])}</li>
        {/volist}
      </ul>
    </div>
  </div>
  <div class="card mb-3">
    <div class="card-header font-weight-bold">循环数据调用演示2</div>
    <div class="card-body">
      <blockquote>通过在模板里使用助手函数(DcTermNavbar)调用栏目分类循环数据。</blockquote>
      <ul class="card-text">
        {volist name=":DcTermNavbar(['result'=>'array','module'=>'example','type'=>'link','limit'=>10,'page'=>false,'sort'=>'term_id','order'=>'asc'])" id="nav"}
        <li>{$nav.navs_id}-{$nav.navs_name}-{$nav.navs_slug}-{:DcUrl('example/nav/detail',['id'=>$nav['navs_id']])}</li>
        {/volist}
      </ul>
    </div>
  </div>
  <div class="card mb-3">
    <div class="card-header d-flex justify-content-between">
      <font>控制器源码(apps/example/controller/Navs.php)</font>
      <a class="font-weight-bold text-purple" href="javascript:;" data-toggle="copy" data-clipboard-target="#controller">复制</a>
    </div>
    <div class="card-body" id="controller">
      {:exampleCode('apps/example/controller/Navs.php')}
    </div>
  </div>
  <div class="card mb-3">
    <div class="card-header d-flex justify-content-between">
      <font>模板源码(apps/example/theme/default/nasv/index.tpl)</font>
      <a class="font-weight-bold text-purple" href="javascript:;" data-toggle="copy" data-clipboard-target="#view">复制</a>
    </div>
    <div class="card-body" id="view">
      {:exampleCode('apps/example/theme/default/navs/index.tpl')}
    </div>
  </div>
</div>
{/block}
<!--footer-->
{block name="footer"}
  {include file="apps/common/view/widget/footer.tpl" /}
{/block}