title: Make controller constructor value global codeigniter
body: <p>Im trying to get the total unread accounts from the database, the value is assigned to <code>$data['head']</code></p>
  
  <p>I want to make the $data['head'] available globally so it will be automatically loaded into the template and displayed on the header.</p>
  
  <p>What is the best way to do this?</p>
  
  <p>Below is my controller</p>
  
  <pre><code>function __construct()
      {
  
      parent::__construct();
      $this-&gt;load-&gt;model('process_model');
      $data['headbody']='includes/header';
      $data['head'] = $this-&gt;process_model-&gt;loadnew($this-&gt;session-&gt;userdata('id'));
  
      }
  
  
  function invform()
      {
          $this-&gt;load-&gt;model('slave');
          $data['body']='slave-account';
  
          $data['questions'] = $this-&gt;slave-&gt;loadq($this-&gt;uri-&gt;segment(3));
  
          $this-&gt;load-&gt;view('includes/template',$data);
      }
  </code></pre>
  
  <p>View</p>
  
  <pre><code>$this-&gt;load-&gt;view($head);
  
   $this-&gt;load-&gt;view($body);
  
   $this-&gt;load-&gt;view('includes/footer');
  </code></pre>