title: How can i call the dynamic page contents in codeigniter
body: <p>I am making a website using Codeigniter</p>
  
  <p>My models are as</p>
  
  <ul>
  <li>For Home Page: Home_model.php(Inside model folder)</li>
  <li>For About Page: About_model.php(Inside model folder)</li>
  </ul>
  
  <p>I have one controller to handle all the pages with calling different methods inside Controller Class.</p>
  
  <p>The home page model is working fine;but when i call the about page
  the inner contents inside about page is giving error As: Message: Undefined variable: a
  Whereas i am simply passing an array to the view of about page
  I have used print_r($a) on the view but the error is same</p>
  
  <hr>
  
  <h2>Controller Code:</h2>
  
  <pre><code>class Pages extends CI_Controller{
  
    public function __construct()
      {
              parent::__construct();
              $this-&gt;load-&gt;model('home_model');
              $this-&gt;load-&gt;model('about_model');
              $this-&gt;load-&gt;helper('url_helper');
      }
      public function index(){
          $page = 'home';
          $test_cms['query']=$this-&gt;home_model-&gt;getcms();
          $test_cms['title'] = 'Home Page';
          $this-&gt;load-&gt;view('templates/header', $page);
          $this-&gt;load-&gt;view('pages/'.$page, $test_cms);
          $this-&gt;load-&gt;view('templates/footer',$page);
  
      }
      public function home(){
      $page = 'home';
          $test_cms['query']=$this-&gt;home_model-&gt;getcms();
          $test_cms['title'] = 'Home Page';
          $this-&gt;load-&gt;view('templates/header', $page);
          $this-&gt;load-&gt;view('pages/'.$page, $test_cms);
          $this-&gt;load-&gt;view('templates/footer',$page);
     }
     public function about(){
      $page = 'about';
  
          $a['dada']=$this-&gt;about_model-&gt;testabout();
          $data['title']='other page';
          $this-&gt;load-&gt;view('templates/header', $page);
          $this-&gt;load-&gt;view('pages/'.$page, $a);
          $this-&gt;load-&gt;view('templates/footer',$page);
     }
   }
  </code></pre>
  
  <hr>
  
  <h2> Home Page Model</h2>
  
  <pre><code>class Home_model extends CI_Model{
  public function __construct()
  {
   $this-&gt;load-&gt;database(); 
  }
  public function getcms() {
      $q = $this-&gt;db-&gt;query('select * from cms');
      if($q-&gt;num_rows() &gt; 0){
          foreach ($q-&gt;result_array() as $row)
          {
              $data[] = $row;
          }
      return $data;
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <hr>
  
  <h2>About Page Model</h2>
  
  <pre><code>class About_model extends CI_Model{
  public function testabout() {
      $about['content']="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
      return $about;
    }   
  </code></pre>
  
  <p>}</p>
  
  <p>Every time when i call the about page it is loading header and footer contents correctly but inner contents of about page saying the variable is undefined.
  whereas i am simply calling the array inside it.</p>
  
  <p>I am beginner.Can you please suggest me where i am going wrong. </p>