$data['page_title'] = 'Your title'; $this->load->view('header'); $this->load->view('menu'); $this->load->view('content', $data); $this->load->view('footer');
$data['page_title'] = 'Your title'; $this->load->view('header'); $this->load->view('menu'); $this->load->view('content', $data); $this->load->view('footer');
$this->load->view('content', $data);
$this->load->view('content', $data);
class MY_Layout extends CI_Controller { // public $header = 'header'; public $footer = 'footer'; // : public function content($views = '', $data = '') { // header if ($this->header) { $this->load->view($this->header, $data); } // , if (is_array($views)) { foreach ($views as $view) { $this->load->view($view, $data); } } else { $this->load->view($views, $data); } // footer if ($this->footer) { $this->load->view($this->footer); } } }
class MY_Layout extends CI_Controller { // public $header = 'header'; public $footer = 'footer'; // : public function content($views = '', $data = '') { // header if ($this->header) { $this->load->view($this->header, $data); } // , if (is_array($views)) { foreach ($views as $view) { $this->load->view($view, $data); } } else { $this->load->view($views, $data); } // footer if ($this->footer) { $this->load->view($this->footer); } } }
class User extends CI_Controller { public function __construct() { parent::__construct(); $this->load->library('MY_Layout'); } public function test() { $data['title'] = 'dynamic_string'; $this->my_layout->content('user/test', $data); } }
class User extends CI_Controller { public function __construct() { parent::__construct(); $this->load->library('MY_Layout'); } public function test() { $data['title'] = 'dynamic_string'; $this->my_layout->content('user/test', $data); } }
$data['title'] = 'dynamic_string'; $views = array( 'menu' => 'menu', 'content' => 'user/test' ); $this->my_layout->content($views, $data);
$data['title'] = 'dynamic_string'; $views = array( 'menu' => 'menu', 'content' => 'user/test' ); $this->my_layout->content($views, $data);
$this->my_layout->header = 'user/custom_user_header'; // or turn off header $this->my_layout->header = FALSE;
$this->my_layout->header = 'user/custom_user_header'; // or turn off header $this->my_layout->header = FALSE;
Source: https://habr.com/ru/post/139875/
All Articles