danieltorscho/ci_template_lib

此包已被废弃,不再维护。未建议替代包。
关于此包最新版本(dev-master)的许可证信息不可用。

简单模板库,包含一些核心功能,可简化CodeIgniter 2.x的开发过程

dev-master 2017-05-15 09:54 UTC

This package is not auto-updated.

Last update: 2023-01-16 23:28:48 UTC


README

简单模板库,包含一些核心功能,可简化CodeIgniter 2.x的开发过程。

如何使用

  1. 将所有文件解压到您的项目根目录。如果提示,请确保覆盖所有文件。
  2. 打开 app/config/autoload.php,将 'template' 添加到 $autoload['libraries']$autoload['config']
  3. 编辑您的模板配置文件 application/config/template.php
  4. 导航到 yourwebsite.dev/index.php/welcome

模板库会自动处理大部分视图逻辑。

在控制器方法内部调用简单的 $this->template->load();,它将自动创建 pagetitlepagenamescriptsstylesheets 变量,并在 load() 函数中没有提供任何内容的情况下,自动加载相应的子视图文件 controller/method.php

文档

加载自定义视图文件
$this->template->load('path/to/view.php');

在自定义模板文件中加载自定义视图文件
$this->template->load('template/login', 'user/login/form');

设置自定义页面标题
$this->template->title('产品页面');

设置自定义面包屑
$this->template->crumb('电子商务', 'ecommerce/index');
$this->template->crumb('产品', 'ecommerce/products');
$this->template->crumb('产品 #391');

添加自定义JavaScript文件加载
$this->template->script('plugin/head.js', TRUE)
$this->template->script('footer.js');

添加自定义CSS文件加载
$this->template->css('print.css', 'print');

设置自定义变量
$this->template->set_item('articles', $articles); // 现在您可以在所有子视图中使用 $articles