Welcome Guest, Not a member yet? Register   Sign In
Use one main controller to load everything else
#1

[eluser]IJzer[/eluser]
Hi,

I'm new to the MVC approach, I used to have my own set of libraries which I used to separate code from html etc etc.

Now I'm trying to figure out how to use CI. There are some things I would like to understand before I can really start using the framework extensivly.

I would like to use one standard html template which contains the main structure of the website. Something like:
Code:
<html>
<head></head>
<body>
<div id="container">
  <div id="top">&lt;?=$top;?&gt;</div>
  <div id="left">&lt;?=$left;?&gt;</div>
  <div id="content">&lt;?=$content;?&gt;</div>
  <div id="bottom">&lt;?=$bottom;?&gt;</div>
</div>
&lt;/body&gt;
&lt;/html&gt;

I want this template to be used for all pages, and the main controller should fill the variables with content, like $left could contain a menu, and $bottom links to the sitemap etc. The content changes every page depends on clicked menuitem.

As far as I can see right now is that when the url /news/article/10 (sample) is called the news controller is called and the news view for articles is displayed.
But I don't want to add all the other extra information in a view over and over again. I want the news view to be loaded in the main template for $content.

I also want do add a right column on the page (for example) and depending on the called url I'd like to show banners or latest news of maybe special offers, etc. etc.

Can anyone tell me if this is possible and how to do this? Or push me in the right direction?

Thanks.
#2

[eluser]Dready[/eluser]
Hello, and welcome to CI !

Please search through the forums you'll find a number of ways of doing what you want. I can give you one of the methods : the template library (here http://williamsconcepts.com/ci/codeignit.../template/).
#3

[eluser]IJzer[/eluser]
Hi Dready,

thanks, I thought I searched properly, but maybe didn't use the right keywords.
I'll look into it.




Theme © iAndrew 2016 - Forum software by © MyBB