Welcome Guest, Not a member yet? Register   Sign In
How to pass database value to all view pages?

Hi All,

I didn't created any common template for every pages. i have admin panel. In the front-end i have pages like
Home, About us, career, etc............. for these menu i have created home controller seperatly and created about us controller seperately.

My About us controller code structure will be like this
public function index()
  $data['title'] = 'About Us';
  $data['news'] = $this->xxx_model->get_news();
  $data['query'] = $this->xxx_model->get_clients_image();
and in view page
<?php include('includes/header.php'); ?>
<div class="span4 blue">
         <h2 class="sub-title"><span>Dedicated Service</span></h2>
                <p>One of the ways we deliver on our commitment is through Dedicated Service. We achieve the same through understanding, Learning, timeliness, responsiveness and proactive   approach.</p>
<p>We create a Win- Win Situation to all our clients.</p></article>
&lt;?php include("includes/footer.php");?&gt;
in footer.php i am passing the query results view
&lt;?php //print_r($news);
   foreach($news as $row){ ?&gt;    
  <li><p><a href="&lt;?php echo site_url('home/get_news_events/'.$row-&gt;id)?&gt;">
   echo $row->news_title;
  }else {
   echo $row->news_title;
  ?&gt;</a><span class="date"> - &lt;?php echo date('F d Y',strtotime($row->created_date)); ?&gt;</span></p></li>
   &lt;?php } ?&gt;

My Problem is i have insert the every controller index page
$data['news'] = $this->xxx_model->get_news();

How to make this dynamic for every controller and make it common for every view. i dont want to pass the data in every controller. it should be one controller. Also Currently i have created many view pages like this.

Please help me.

Theme © iAndrew 2016 - Forum software by © MyBB