CodeIgniter: Help in include files

Hi,

I am a totally noob in CI. I am sure there are people on this forum who are good at CodeIgniter. Please bear with me. I have a petty set of problems which I am finding answers for if I am to stick with CI.

Every page has many parts. Header, Footer, Images, CSS, Config Variables (my own not CIs). My questions are

  1. If a page has Header and Footer, do I make model-view-controller set for each of them.

  2. If yes then this is definitely time consuming.

  3. If no, where(location inside the application folder) to make my Include folder where I can put the header, footer files.

  4. Can I use the Database class in these include (header,footer, category list) php files directly without going through MVC everytime.

  5. How to include these files in my main MVC page.

  6. Since these file will be needed on more than one pages, how can I make them global with the option to include them at some places and not include them some places.

  7. Where to put my CSS, Images and .js files. Should I put them on the document root.

  8. The config variables I need like site title, contact us email etc. are going to be loaded from the database. How can I do that, I’m basically stuck with file inclusion and going through MVC for each step.

  9. Can anyone please provide me with a sample set of files just to get me acquainted with the heirarchy.

I hope these questions make sense. I am using CI 1.7 on PHP4. My URL is like http://localhost/site/. I have managed to hide the index.php through htaccess though. smile

A timely reply would be greatly appreciated.

Best Regards

Khuram

I hate doing this, more so when you obviously invested time in compiling your post, but all your questions are answered in the CI Documentation.

I knew my brother would come to my aid.
I came here after reading about 30 pages of documentation.
I am sure you can do better than that. please :frowning:

You’re persistent, I’ll give you that. :slight_smile:

You can include multiple partial views in any view, so yes, you can use the same header and footer for example in every page.

You place all view elements partial or otherwise in the views folder.

You should not use the database layer inside the view, doing so would violate the point of using the MVC principle in the first place. I’m not even entirely sure you can, even if you wanted too.

Remember, ALL data must be obtained with a model, and passed by the controller to the view.

All CSS, JS and images must be placed in your public root, remember to use CI’s base_url() function in your view to help you set the paths to these files in your views.

I’m unsure of what you mean with regards to your config statement.

Hehehe Thanks
Never mind about config, I have got some replies on my thread over at CI forum
I think i can give it a shot now.
Much thanks Silver.

Believe me, Thanks to the Al-Mighty,

Its starting to make sense.
Much thanx to you too.

There is only one thing that i havent been able to understand.
Lets say on my template page, I have to load a list of categories in a table.

Ideally there should be a controller for template which can be called from anyother control to initialize the stuff.
I havent been able to find this out anywhere.
Right now, I am having to do this in every new page that I make.


$this->load->model('template/template','TemplateFunctions', TRUE);
$data['cats'] = $this->TemplateFunctions->get_categories();
$this->load->view('template/template', $data);

Ideally this is not the best situation. Please advice me into how to make a master control which I include in every control and it knows how to react.