Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you organize your template structure in CodeIgniter?
    primarykey
    data
    text
    <p>I will be building a CMS for my final Web Development course project, and i've been challenged by my teacher creating it in an MVC system, and for now, I'll be using CodeIgniter.</p> <p>Therefore, I would like to know how do you organize your file / folder structure.</p> <p>I will be using a simple templating system: - For now I have a templates.php config file that is being autoloaded and says the name of the selected template, and the absolute path to it. - The templates folder is inside the views folder (is this the most correct way to do this?) - Right now I am having some problem to access .css files through the files in the view, and, from what I've read people usually put all that files outside the application folder.</p> <p>How do you normally do it? And, as seeing what I am building, what advices can you give me? Shouldn't views contain all the stuff from templates? (including CSS inside the folder of templates)</p> <p>Thanks.</p> <p><em>(i'm using the Code Ignitor 2.1.0)</em></p> <p>EDIT:</p> <p>Right now, after structured all the files and folders, I am in a dilemma. I have added the following in constants.php</p> <pre><code>&lt;!-- language: lang-php --&gt; $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/' ); </code></pre> <p>(if I didn't define the selected_template and template_abs_path I could play with them in the constants)</p> <p>And i'm including them in the HTML like this:</p> <pre><code>&lt;!-- language: lang-html --&gt; &lt;link rel="stylesheet" type="text/css" href="&lt;?=CSS_PATH;?&gt;style.css" /&gt; </code></pre> <p>But now, I was trying to get a title stored in config too, but I can't do it, because I need all this variables to be in the other templates.php file that I had created previously, otherwise it will not recognize my variables. (I have templates autoloading)</p> <p>templates.php</p> <pre><code>&lt;!-- language: lang-php --&gt; &lt;?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']; </code></pre> <p>header.php</p> <pre><code>&lt;div id="logo"&gt; &lt;h1&gt;&lt;a href="#"&gt;&lt;?=$this-&gt;config-&gt;item('title');?&gt;&lt;/a&gt;&lt;/h1&gt; &lt;/div&gt; </code></pre> <p>Therefore, do I need to have both config to have it working on my website? It really doesn't make much sense for me...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload