php - How do I pass isset value to multiple views with codeigniter -
i have isset()
value calculate raw count , displays count in admin_messages.php page want pass same value view_home.php how can that?
here view
<li> <a href="#"> <i class="icon-home"></i> inbox <strong><?php if(isset($count)){echo $count;}?></strong> </a> </li>
here controller
function messages() { $data['records'] = $this->mod_contactus->get_records(); $data['count'] =$this->mod_contactus->message_count(); $this->load->view('admin/admin_messages',$data); }
the controller friend here. try - uses magic method __construct()
. edit suit needs.
<?php class mycontroller extends ci_controller { private $message_count = 0; // code called here executed when class initialised, don't forget call parent::__construct(); execute codeigniter init code too. public function __construct() { parent::__construct(); $this->load->model('mod_contact'); $this->message_count = $this->mod_contact->message_count(); } public function messages() { $data['records'] = $this->mod_contactus->get_records(); $data['count'] = $this->message_count; $this->load->view('admin/admin_messages',$data); } public function another_function() { $data['records'] = $this->mod_contactus->get_records(); $data['count'] = $this->message_count; // same value $this->load->view('admin/another_function',$data); } }
Comments
Post a Comment