Welcome Guest, Not a member yet? Register   Sign In
One header in all controllers
#1

[eluser]raduenea[/eluser]
I have a header views like:
Code:
<div id="big_table">

<div id="banner">
    banner
    </div>
    
<div id="left">
    &lt;?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;
  ?&gt;
    </div>

and footer views:
Code:
</div>

<div class="clear"></div>

&lt;/body&gt;
&lt;/html&gt;

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


Messages In This Thread
One header in all controllers - by El Forum - 05-25-2013, 03:49 PM
One header in all controllers - by El Forum - 05-25-2013, 05:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB