is there way load controller view ?
here affter.. want use 1 view multiple times, view being loaded separate controller gives view, information db.so becouse of information model can't set $this-load->view();
, etc. there way thing, or has better way ?
i think lot of sites face similar challenges, including 1 i'm working on loads same db content sidebar on every page in site. implemented combination of library , helper:
- put data logic library (mine named common.php). in addition interfacing database, may want library store data in local variable in case want reference multiple times on single load.
public function get_total_items() { if ($this->_total_items === null) { $row = $this->ci->db->query("select count(*) items")->row(); $this->_total_items = $row[0]; } return $this->_total_items; }
create helper load library. (don't load libraries within view!) have my_text_helper loads library , returns data:
function total_items() { $ci =& get_instance(); return $ci->common->get_total_items(); }
call helper function within view.
<p> total items: <?php echo total_items(); ?> </p>
Comments
Post a Comment