Reputation:
can you please tell how to access view components (div ...) from controller in Codeigniter,
the purpose is to load profiles from database and show or hide some components according to the response
and thank you.
Upvotes: 0
Views: 2105
Reputation: 2967
See Adding Dynamic Data to the View,
https://www.codeigniter.com/userguide2/general/views.html
Upvotes: 0
Reputation: 342
Pass the variable from the controller into the view, and then determine whether or not to display sections of each profile. As an example:
Controller:
$data['profile'] = $this->my_model->get_profile();
$this->load->view('profileView', $data);
Then, in the view, you can test for values and display sections.
<?php if ($profile = "admin"){ ?>
<div id="AdminDiv">
Special Admin Content
</div>
<?php } ?>
Upvotes: 1