Reputation: 1063
Is there a way to dynamically include files through the controller, just as you would do include('path_to_file').
The only advice I've gotten was to define it like
$data = array('var'=>'path1','var2'=>'path2');
and pass it through the load view, but this doesn't load the files, so I'm basically back where I started.
Upvotes: 0
Views: 10011
Reputation: 37711
Like Repox said, you should follow the MVC structure. Generally, if you plan to include classes (functionality), use models; if you want to include presentation (html), use views. And all this should be done from a controller. For example:
$this->load->model('my_functions');
$this->my_functions->do_something();
$this->load->view('header');
$this->load->view('content');
$this->load->view('footer');
If you really need it, you can also call models and views from a view. Hope this clears it up a bit.
Upvotes: 2
Reputation: 15475
Short answer - no.
A more detailed answer would be providing you with details on how to use the MVC correctly.
Splitting up the file you wan't to include into models, views and controllers would be the correct thing to do. That is 'the dynamic way to include files' in CI.
Upvotes: 1