如何在codeigniter中集成html模板 [英] How can integrate html template in codeigniter

查看:545
本文介绍了如何在codeigniter中集成html模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是codeigniter的新手。请告诉我如何在codeigniter中集成或安装一个html主题/模板? (我的css文件夹path = news / css和应用程序文件夹path = news / application where news是我的主文件夹)

I'm new to codeigniter. please tell me how can I integrate or install a html theme/template in codeigniter ? (my css folder path=news/css and application folder path=news/application where news is my main folder)

-thanks。

推荐答案

这是一个非常简单,非常强大的方法在codeigniter中做模板,也很灵活。

http://news.dice.com/ 2013/02/18 / how-to-build-a-to-do-app-with-codeigniter /

This is a very simple, very powerful way to do templates in codeigniter that is also very flexible.
http://news.dice.com/2013/02/18/how-to-build-a-to-do-app-with-codeigniter/

忽略标题,课程是关于在CI中设置模板。

ignore the title, most of the lesson is about setting up templates in CI.

请注意,我第一次暴露于这种方法从一个jeffrey方式CI教程net.tutsplus.com
所有这些都值得检查: http://net.tutsplus.com/sessions/codeigniter-from-scratch/

Note that i was first exposed to this method from a jeffrey way CI tutorial on net.tutsplus.com All of them are worth checking out: http://net.tutsplus.com/sessions/codeigniter-from-scratch/

编辑 - 确定这是足够好的除了发布。因此,在教程中,在template.php页面上,您将看到

edit -- ok this is good enough addition to post. So in the tutorial, on the template.php page, you will see

 $this->load->view($maincontent);

这很酷。但是这更好:

// load your header views

 $templatefolder = 'beta/';

 if(isset($content01))
 $this->load->view($templatefolder.$content01);

 if(isset($content02))
 $this->load->view($templatefolder.$content02);

 if(isset($content03))
 $this->load->view($templatefolder.$content03);

 // load your footer views 

maincontent,我已经在$ content1,$ content2等引用。因为我们正在做,如果isset它们都不是必需的。这样你可以轻松地发送多个视图文件到模板。或者没有,如果你只是显示一条消息,等等。还要注意,我们有$模板文件夹 - 这样你可以轻松地重用模板文件的其他网站模板,即使有相同的内容。

so instead of calling the view "maincontent", i've put in references to $content1, $content2, etc. Because we are doing if isset none of them are required. that way you can easily send more then one view file to the template. Or none at all if you are just showing a message, etc. Also notice that we have $templatefolder - that way you can easily reuse the template file for other site templates, even with the same content.

(类似于教程)

 $data['content01'] = 'codeigniterrawks';
 $data['content02'] = 'mypetlion';
 // beta template
 $this->load->view( 'template_beta', $data );

请注意,如果我想将那些相同的视图文件放入不同的模板, p>

note how easy it is if i want to bring in those same view files into a different template

 $data['content01'] = 'codeigniterrawks';
 $data['content02'] = 'mypetlion';
 // alpha template
 $this->load->view( 'template_alpha', $data );

这篇关于如何在codeigniter中集成html模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆