[eluser]smalter[/eluser]
EDIT: Ok. I think that you are better going to understand with the exemple.
By thinking, i want to include a *controller* in my other views... But I know that it is not a solution.
Thanks for your help!
Exemple:
Code:
// Shop: Main Controller
class Shop extends Controller {
function shop {
parent::Controller();
// Load somes library, plugins or helper
$this->load->helper('blabla');
$this->load->library('blabla');
$this->load->model('my_model');
}
function index() {
$data['title'] = 'This is my shop!';
$data['list_item'] = $this->my_model->lastentries();
$this->load->view('homepage', $data);
}
}
// Homepage: Main view
// Load header view
<?=$this->load->view('header', $data)?>
<?=$this->load->view('content_of_my_page', $data)?>
// Display last entries in the bottom of the page
<?=$this->load->view('lastentries_view', $data)?>
<?=$this->load->view('footer', $data)?>
// Lastentries_view: view
<?
<?php foreach($list_item as $item): ?>
echo $item->lastentries();
<?php endforeach;?>
?>
Ok, it is working.
But now, i decide to include "lastentries_view" in an other view "contact.php", on the top.
I make a new view and controller:
Code:
// Contact controller
class Contact extends Controller {
function contact {
parent::Controller();
// Load somes library, plugins or helper
$this->load->helper('blabla');
$this->load->library('blabla');
}
function index() {
$data['title'] = 'Contact page';
$data['content'] 'Content of my contact page';
$this->load->view('contact', $data);
}
}
// Contact: view
// Load header view
<?=$this->load->view('header', $data)?>
// Display last entries before the content
<?=$this->load->view('lastentries_view', $data)?>
<?=$content;?>
<?=$this->load->view('footer', $data)?>
In the second exemple, the value "$list_item" used in "lastentries_view" doesn't exist.
This is make an error.
How I can get organized to be able to move a view (lastentries_view) and display it in different other views, but by keeping the access to variables? (Homepage on the bottom, Contact page on the top,...)
Cheers.