• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to pass database value to all view pages?

#1
[eluser]rashgang[/eluser]
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
Code:
public function index()
{  
  $data['title'] = 'About Us';
  $data['news'] = $this->xxx_model->get_news();
  $data['query'] = $this->xxx_model->get_clients_image();
  $this->load->view('about_us',$data);
  
}
and in view page
Code:
<?php include('includes/header.php'); ?>
<div class="span4 blue">
    <article>
         <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>
        </div>
&lt;?php include("includes/footer.php");?&gt;
in footer.php i am passing the query results view
Code:
&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;">
  &lt;?php
  if($row->category=="news"){
   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
Code:
$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.





Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.