CodeIgniter:使用模板的提示 [英] CodeIgniter: tips for using templates
问题描述
刚刚开始使用Codeigniter(昨天),我想知道人们使用的模板功能是什么?
是否可以创建一个视图, / p>
感谢,
Jonesy
模板的想法是创建一个具有公共头的共享布局。页脚等,然后只是有一个body,每页更改。
在最基本的级别,你可以只包括页眉和页脚在每个视图, :
load-> view('header'); ?>
这是我的页面。
load-> view('footer'); ?>
这可以很好,但开始构建任何实际大小的应用程序,你会发现问题。
有多种方式进行模板化,但我多年来使用的方式是模板库。它通过20-30个项目不同的项目看到我,并被许多人使用,所以你知道它的尝试和测试。
Just started using Codeigniter (yesterday) and am wondering what templating features people are using?
Is it possible to create a view and just load it whenerever necessary?
Thanks,
Jonesy
The idea of templating is to create a shared layout with a common header. footer etc and then just have a "body" that changes per-page.
At the most basic level you can just include header and footer inside each of your views like this:
load->view('header'); ?>
This is my page.
load->view('footer'); ?>
That can be fine but start building an application of any real size and you'll find problems.
There are million ways of doing templating, but the way I have used for years is this Template library. It's seen me through 20-30 projects varying projects and is used by many so you know it's tried and tested.
这篇关于CodeIgniter:使用模板的提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!