Welcome Guest, Not a member yet? Register   Sign In
I can't understand how to use MVC ...
#2

[eluser]Bart v B[/eluser]
Wel, it is not complicated. Smile

The controller controles things.
The model does the things.
The view is for presentation.
So with that knowlege we can do a step more.

The presentation with alway's the same menu and top, then you can do that like this:
create in the view folder a new foldes named: includes.
So /application/view/includes/

In that folder create a new php file called: template.php
And add some code like this:
Code:
<?php
// load the header
$this->load->view('includes/topmenu');

// load the sidebar
$this->load->view('includes/sidebar');

// load the main_content variabele so we can dynamic call other views
$this->load->view($main_content);

// load the footer
$this->load->view(includes/footer);
    
?>

in the includes/topmenu.php you put the code from your menu.
in the includes/sidebar.php you put the code from your sidebar

$main_content... // later Tongue

In the includes/footer.php you put the code from your footer. (something like </bode>&lt;/html&gtWink

Now we have a variabele to do someting with.

in your controller:

Code:
&lt;?php

class Content extends CI_Controller
{
   public funtion index()
   {

       // add some text
       $data['hello'] = 'Hello Codeigniter';
      // here we create a view with the content what you wanna show.
      $data['main_content'] = 'content';

     // here we call the template and show something.
     $this->load->view('includes/template', $data);
   }
}

Now when you create a content.php in your view folder.

Code:
<h1>&lt;?php echo $hello?;></h1>

And now you should see 'Hello Codeigniter' when you call it from your url.


Messages In This Thread
I can't understand how to use MVC ... - by El Forum - 08-05-2011, 11:34 AM
I can't understand how to use MVC ... - by El Forum - 08-05-2011, 12:00 PM
I can't understand how to use MVC ... - by El Forum - 08-05-2011, 12:05 PM
I can't understand how to use MVC ... - by El Forum - 08-05-2011, 12:20 PM
I can't understand how to use MVC ... - by El Forum - 08-05-2011, 12:24 PM
I can't understand how to use MVC ... - by El Forum - 08-05-2011, 12:41 PM
I can't understand how to use MVC ... - by El Forum - 08-05-2011, 12:56 PM
I can't understand how to use MVC ... - by El Forum - 08-05-2011, 01:00 PM
I can't understand how to use MVC ... - by El Forum - 08-05-2011, 01:10 PM
I can't understand how to use MVC ... - by El Forum - 08-05-2011, 01:14 PM
I can't understand how to use MVC ... - by El Forum - 08-06-2011, 11:36 AM
I can't understand how to use MVC ... - by El Forum - 08-06-2011, 11:38 AM
I can't understand how to use MVC ... - by El Forum - 08-06-2011, 11:40 AM
I can't understand how to use MVC ... - by El Forum - 08-06-2011, 11:52 AM
I can't understand how to use MVC ... - by El Forum - 08-07-2011, 01:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB