[eluser]raduenea[/eluser]
I have a header views like:
Code:
<div id="big_table">
<div id="banner">
banner
</div>
<div id="left">
<?php
foreach ($array as $key => $value):
//echo $key . ' -> ' . $value . '<br>';
echo anchor('picturi/' . $value['link'] . '/' . $value['id'] , $key , array('title' => 'Picturi ' . $value['link'])) . '<br>';
endforeach;
//echo $link;
?>
</div>
and footer views:
Code:
</div>
<div class="clear"></div>
</body>
</html>
And two classes.
Home controller
Code:
class Home extends CI_Controller {
public function index()
{
$data['title'] = "About the Code Igniter Sample Application";
$data['array'] = array(
'Abstracte' => array (
'link' => 'abstracte',
'id' => '1'
),
'Munti' => array (
'link' => 'munti',
'id' => '2'
),
'Oameni' => array (
'link' => 'oameni',
'id' => '3'
)
);
//$data['link'] = $this->uri->segment(2, 0);
$this->load->helper('url');
$this->load->helper('array');
$this->load->view('header', $data);
$this->load->view('home_message');
$this->load->view('footer');
}
}
and
Picturi controller
Code:
class Picturi extends CI_Controller {
public function general()
{
$data['title'] = "Picturi";
$data['id'] = $this->uri->segment(3);
if($data['id'] == 1)
{
$data['show_pic'] = array('unu','doi','trei');
}
elseif($data['id'] == 2)
{
$data['show_pic'] = array('patru','cinci','sase');
}
$this->load->helper('url');
$this->load->view('header', $data);
$this->load->view('picturi');
$this->load->view('footer');
}
}
In header I have the menu that I need in all controllers. That menu is generated with array in home controller.
I can copy and paste the array code in picturi controller, but I will have more controllers and I dont't think that copy/paste it's ok.
Please help me where can I generate the header only one to be include in all controllers ?
Thanks