CodeIgniter - Displaying and entering dynamic meta data -
i have started using codeigniter ... im finding quite good, although have bit of issue.
whats best way handle meta data? ... in views folder, have created folder called 'includes' in there have added header, footer, nav views.
so i'm taking each controller meta data needs entered , passed header view.
if examples of how go this, fantastic.
cheers,
create new file in libraries folder:
<?php if ( ! defined('basepath')) exit('no direct script access allowed'); class view_lib { public function __construct() { $this->ci =& get_instance(); } public function load_view($template, $data = null) { $this->ci->load->view('header', $data); $this->ci->load->view($template); $this->ci->load->view('footer'); } } /* end of file view_lib.php */ /* location: ./system/application/libraries/view_lib.php */
then load library in controller:
$this->load->library('view_lib');
then call view file in function this:
$this->view_lib->load_view('name_of_view_file', $data);
or (if call static file without data pass):
$this->view_lib->load_view('name_of_view_file');
there many ways of doing this, 1 works nicely applications working on. in 1 of projects have multiple functions in view_lib library load or without sidebar, different headers , footers depending if user logged in.
hope helps, cheers.
Comments
Post a Comment