CodeIgniter Forums

Full Version: Layout manager I think.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Pet[/eluser]
Hi there. Can you please guide me on some layout manager i want to implement on my website. The problem is this, i am trying to make a controller for a certain view. eg(widget_navigation). Now what i accomplish so far is only the layout.I am having a hard time figuring out how can I can the controller when I load the home page and then the home controller will load the home view inside that home view individual widget will be included but all the functionality of those widget should come to a certain controller.eg(widget_controller). I know it can be accomplished by this code:
class Home extends CI_Controller {


public function index()
{
$data=array(
'id'=>23,
'username'=>'Administrator'
);
$string=$this->load->view('home/header',$data,TRUE);
$this->load->view('home',$string);
}
}

What I was trying to do is not to make the whole code to look like this on instead ill just call the home controller then go to home view after that widgets will be automatically loaded without calling it in home controller.

Please please any suggestion would help. Im trying to figure out if possible to make a widget loader of some kind. Just don't know how..

Thank you !!!!!

El Forum

[eluser]CroNiX[/eluser]
The 2nd parameter to load:view() must be an array just like you are doing when you are loading your header view.

Code:
public function index()
{
  $data=array(
    ‘id’=>23,
    ‘username’=>‘Administrator’
  );
  $data['string'] = $this->load->view(‘home/header’, $data, TRUE);
  $this->load->view(‘home’, $data);
}

Then in your "home.php" view file, just echo $string.