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

[eluser]stiginshanghai[/eluser]
Why not simply include the topmenu and sidebar from the page template?
#12

[eluser]Ali Kimiagar[/eluser]
[quote author="stiginshanghai" date="1312670210"]Why not simply include the topmenu and sidebar from the page template?[/quote]

Because top menu and sidebar have their own controllers ... they are not static !!!!
#13

[eluser]stiginshanghai[/eluser]
[quote author="Ali Kimiagar" date="1312670295"][quote author="stiginshanghai" date="1312670210"]Why not simply include the topmenu and sidebar from the page template?[/quote]

Because top menu and sidebar have their own controllers ... they are not static !!!![/quote]

Then they shouldnt be controller related, but in some wider context, f.x. a hook. Meaning their variable content shouldnt be related to the specific controller if the variable content is general for many controlers (say "member area").
#14

[eluser]stiginshanghai[/eluser]
Or other option, though im not that much into IC to know if thats possible: you make 1 controller which has ur basic top menu and side bar related code, and then you let the others who needs those extend that controller.
#15

[eluser]Bart v B[/eluser]
What you can do is create a constructor:

Code:
<?php
class someting extends CI_Controller
{
   private = $nav;

   function __construct()
   {
      parent::__construct();
      $this->nav = array(
              array('Home', site_url('home')),
                     array('Guestbook', site_url('guestbook')),
                     array('portfolio', site_url('portfolio'))
                );
   }

   public function index()
   {
      $this->load->vars(array('NavigationArray' => $this->nav));
      $this->load->view('some_view');
   }
}

some_view.php

Code:
<div>
&lt;?php foreach($NavigationArray as $entry): ?&gt;
   <a href="&lt;?php echo $entry[1];?&gt;">&lt;?php echo $entry[0];?&gt;</a> |
    &lt;?php endforeach; ?&gt;
</div>

In this way you don't have to create controllers.
Menu's, sidebars are a part of presentation, so it have to be in the view. Wink
Remember my first words:
Quote:-> The controller controles things.
-> The model does the things.
-> The view is for presentation.




Theme © iAndrew 2016 - Forum software by © MyBB