0

I am new to the CodeIgniter fw of PHP and generally have medium experience with MVC. I am working on a project where using modules will make my life a lot easier.

There is something regarding the way you call the modules that is a bit unclear in my head. The solution I had was to call the full module in the controller and pass the code as a variable in the view and then just echo it. Here is a sample of that logic

// Controller
$var['login'] = // code that calls the module
$this->load->view('index', $var);

// View
<div class='navbar'> 
    <?= $login; ?>
</div>

However after a small search, I found this solution Creating Block/Modules in Code Igniter (String path of the module (view2) in the controller, pass it to view1 and then call it in the main view): .

Which of the 2 logics is the one that follows the MVC standards in a better way?

UPDATE: I have found the answer on how to do both here: how to load view into another view codeigniter 2.1? but my question remains the same. Which is the best logic that follows the MVC standards better?

Community
  • 1
  • 1
Harris Geo
  • 239
  • 2
  • 4
  • 14

1 Answers1

0

first create model object like $model = new mymodel

where u want to call do this $this->model->your_function_name($parameter);

user3546207
  • 20
  • 1
  • 3