php – 如何在CodeIgniter中组织模板结构?
我将为我的最终Web开发课程项目建立一个CMS,而且我的老师在MVC系统中创建了一个CMS,现在我将使用CodeIgniter.
因此,我想知道如何组织文件/文件夹结构. 我将使用一个简单的模板系统: 你通常如何做?而且,看到我正在建设什么,你能给我什么建议? 谢谢. (我正在使用代码Ignitor 2.1.0) 编辑: 现在,在结构化所有文件和文件夹之后,我处于一个两难的境地.我已经在constants.php中添加了以下内容 <!-- language: lang-php --> $config['selected_template'] = 'oceania'; $config['template_abs_path'] = 'assets/templates/'.$config['selected_template']; define('IMAGES_PATH',$config['template_abs_path'].'/img/' ); define('CSS_PATH',$config['template_abs_path'].'/css/' ); define('SCRIPTS_PATH',$config['template_abs_path'].'/js/' ); (如果我没有定义selected_template和template_abs_path,我可以在常量中使用它们) 我正在把它们包含在HTML中: <!-- language: lang-html --> <link rel="stylesheet" type="text/css" href="<?=CSS_PATH;?>style.css" /> 但是现在,我试图获得一个保存在配置中的标题,但是我无法做到这一点,因为我需要所有这些变量在我之前创建的其他templates.php文件中,否则它不会识别我的变量. (我有模板自动加载) templates.php <!-- language: lang-php --> <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); $config['title'] = 'Title of the website'; $config['selected_template'] = 'oceania'; $config['template_abs_path'] = 'templates/'.$config['selected_template']; header.php文件 <div id="logo"> <h1><a href="#"><?=$this->config->item('title');?></a></h1> </div> 因此,我需要使用这两个配置才能在我的网站上运行吗?对我来说真的没有什么意义
一个很好的文件/文件夹结构如下:
website_folder/ –––– application/ –––––––– config/ –––––––––––– autoload.php –––––––––––– config.php –––––––––––– ... –––––––– controllers/ –––––––––––– examples.php –––––––––––– index.html –––––––––––– welcome.php –––––––– ... –––––––– views/ ––––––––---- templates/ ––––––––-------- backend.php ––––––––-------- frontend.php –––––––––––– .... –––––––––––– example.php –––––––––––– index.html –––––––––––– welcome_message.php –––– assets/ –––––––– css/ –––––––– js/ –––––––– images/ –––––––– templates/ ––––––––---- frontend/ ––––––––-------- css/ ––––––––-------- js/ ––––––––-------- images/ ––––––––---- backend/ ––––––––-------- css/ ––––––––-------- js/ ––––––––-------- images/ –––––––– uploads/ –––––––– index.html –––– system/ –––– user_guide/ –––– index.php –––– license.txt 这只是一个建议.因此,您将在views / templates和您的css / js文件中的assets / templates / (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |