循环数据调用演示1
通过模板标签volist循环显示控制器已查询定义的数据列表。
  • 3267-实例分类4-shilifenlei4-https://demo.daicuo.org/example/category/detail?id=3267
  • 3266-实例分类3-shilifenlei3-https://demo.daicuo.org/example/category/detail?id=3266
  • 3265-实例分类2-shilifenlei2-https://demo.daicuo.org/example/category/detail?id=3265
  • 3264-实例分类1-shilifenlei1-https://demo.daicuo.org/example/category/detail?id=3264
循环数据调用演示2
通过在模板里使用助手函数(DcTermSelect)调用栏目分类循环数据。
  • 3264-实例分类1-shilifenlei1-https://demo.daicuo.org/example/category/detail?id=3264
  • 3265-实例分类2-shilifenlei2-https://demo.daicuo.org/example/category/detail?id=3265
  • 3266-实例分类3-shilifenlei3-https://demo.daicuo.org/example/category/detail?id=3266
  • 3267-实例分类4-shilifenlei4-https://demo.daicuo.org/example/category/detail?id=3267
控制器源码(apps/example/controller/Category.php) 复制
<?php
namespace app\example\controller;

use 
app\common\controller\Front;

class 
Category extends Front
{
    public function 
_initialize()
    {
        
parent::_initialize();
    }
    
    public function 
index()
    {   
        
//查询数据
        
$list model('common/Category','loglic')->select([
            
'cache'  => false,
            
'result' => 'array',
            
'module' => 'example',
            
'limit'  => 10,
            
'page'   => false,
            
'sort'   => 'term_id',
            
'order'  => 'desc',
        ]);
        
//变量定义
        
$this->assign('data',$list);
        
//加载模板
        
return $this->fetch();
    }
}
模板源码(apps/example/theme/default/category/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="type"}
        <li>{$type.term_id}-{$type.term_name}-{$type.term_slug}-{:DcUrl('example/category/detail',['id'=>$type['term_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>通过在模板里使用助手函数(DcTermSelect)调用栏目分类循环数据。</blockquote>
      <ul class="card-text">
        {volist name=":DcTermSelect(['result'=>'array','module'=>'example','controll'=>'category','limit'=>10,'page'=>false,'sort'=>'term_id','order'=>'asc'])" id="type"}
        <li>{$type.term_id}-{$type.term_name}-{$type.term_slug}-{:DcUrl('example/category/detail',['id'=>$type['term_id']])}</li>
        {/volist}
      </ul>
    </div>
  </div>
  <div class="card mb-3">
    <div class="card-header d-flex justify-content-between">
      <font>控制器源码(apps/example/controller/Category.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/Category.php')}
    </div>
  </div>
  <div class="card mb-3">
    <div class="card-header d-flex justify-content-between">
      <font>模板源码(apps/example/theme/default/category/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/category/index.tpl')}
    </div>
  </div>
</div>
{/block}
<!--footer-->
{block name="footer"}
  {include file="apps/common/view/widget/footer.tpl" /}
{/block}