Welcome Guest, Not a member yet? Register   Sign In
Best way to organise pages?
#1

[eluser]jp612[/eluser]
So what I have just created is a basic layout template with dynamic pages. So far I have one controller file for my individual pages

Code:
<?php
class Home extends controller {
    
    function index() {
        
        $this->load->view('layout-parts/main-template');
        
    }
    
    
    
    
    
}


?>

I call my main template here (which is in views) which looks like this:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;

&lt;title&gt;&lt;/title>
&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url() . 'codei01/assets/css/style.css'; ?&gt;" /&gt;  
&lt;/head&gt;

&lt;body&gt;
<div id="container">
&lt;?php
    $this->load->view('layout-parts/header');
    $this->load->view('layout-parts/navbar');
    $this->load->view('layout-parts/maincontent'); // block variables are in maincontent.php
    $this->load->view('layout-parts/footer');
?&gt;        
&lt;!-- end #container --&gt;</div>
&lt;/body&gt;
&lt;/html&gt;

And from within the maincontent.php (also under views) I call the page like so

Code:
<div id="maincontent">
    
    &lt;?php
        $this->load->view($page);
    ?&gt;

&lt;!-- end #maincontent --&gt;</div>

then i want to create a folder under views called pages where all the different pages will be stored. Then also under views i want to create a page-blocks folder where all the page elements (divs) will be stored, these will be called from within the page file.

However now i feel like im not doing alot from the controller and all my calling will be scattered all over the place. Is this bad?

the actual page variable will be defined in the controller along with page titles etc.

Is this a good idea for a setup or is there a better way to do this?

PS Im new to Code Igniter
#2

[eluser]AlexJ[/eluser]
You can use the template library for CI, it gives you a more finegrined control over the template library: http://ellislab.com/forums/viewthread/88452/




Theme © iAndrew 2016 - Forum software by © MyBB