Welcome Guest, Not a member yet? Register   Sign In
CI3 - wiredesignz HMVC
#7

(This post was last modified: 06-04-2015, 08:23 AM by mwhitney.)

http://www.codeigniter.com/user_guide/ge...o-the-view

Load the data in your controller, add whatever you want from the loaded data to an array of key => value pairs, and pass the array to your view. The keys in the array will be converted to variable names which you can use in your view to access that value in your view.

PHP Code:
// Controller
class Example extends MY_Controller
{
 
   public function __construct()
 
   {
 
        parent::__construct();
 
   }

 
   public function index()
 
   {
 
       $dbData $this->db->get('something');
 
       $data = array(
 
           'title' => 'Index Title',
 
           'records' => $dbData,
 
       );

 
       // Now you can use $title and $records in your view 
 
       // to get 'Index Title' and $dbData, respectively.
 
       $this->load->view('index'$data);
 
   }


A template library can include methods to add this data if it calls $this->load->view() for you. For example, Bonfire's Template library uses
Code:
Template::set('variableName', 'value');
Reply


Messages In This Thread
CI3 - wiredesignz HMVC - by ambush-reality - 06-03-2015, 09:18 AM
RE: CI3 - wiredesignz HMVC - by davicotico - 06-03-2015, 11:00 AM
RE: CI3 - wiredesignz HMVC - by ambush-reality - 06-03-2015, 12:20 PM
RE: CI3 - wiredesignz HMVC - by RogerMore - 06-04-2015, 12:36 AM
RE: CI3 - wiredesignz HMVC - by mwhitney - 06-04-2015, 07:13 AM
RE: CI3 - wiredesignz HMVC - by ambush-reality - 06-04-2015, 08:11 AM
RE: CI3 - wiredesignz HMVC - by mwhitney - 06-04-2015, 08:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB