Welcome Guest, Not a member yet? Register   Sign In
How do you include your pages ?

Hi everybody,
I'd like to know how do you includes your pages with CI ?
Do you include header, next you've got your content and next your footer, or do you do it an other way ?

Because when I didn't use CI, I did like this :

HTML Stuff
$rep = array ("news", "roster", "wars", "contact", "downloads", "palmares", "teams");
if(isset($_GET["page"]) && file_exists($_GET["rub"]."/".$_GET["page"] .".php") && in_array ($_GET["rub"], $rep))
       include dirname(__FILE__)."/".$_GET['rub']."/".$_GET['page'].".php";
   else {
       include dirname(__FILE__)."/news/index.php";
HTML Stuff

And I think it's very usefull.

[eluser]Jesse B.[/eluser]
One of the neat features of CI is that it does this kind of logic for you automatically.

Based on your example, you'd have controllers for "news", "roster", "wars", "contact", "downloads", "palmares", and "teams". Within those controllers, you could have methods for "add", "view", "edit", "delete", or whatever makes sense.

The controllers define what your application does. CI performs routing to translate a URL into the appropriate controller and method to call. For example, by default, a URL like this:


...would call the view() method of the roster controller. 21 would be passed as a parameter of view().

When processing is finished, a controller will typically load one or more views, which are like templates for your application. You could make one view per controller, or you could make common views for the site header and footer, and call those in each controller. The choice is based on what makes sense to you.

I know all that first part Wink

So, the only way to proceed is in the view :




you could look at using some of the nice template libraries available in the wiki, there are several available, and I am using one of them which has a "master template" implementation. In my case then there is no such thing as header and footer, because it is all co-existing in the master template file.

Goodluck Smile

Oh, nice !
I didn't know that, I'll take a look.

Theme © iAndrew 2016 - Forum software by © MyBB