[eluser]kaos78414[/eluser]
In an effort to better understand MVC structure, I have a few general questions.
Firstly, what is the difference between helper and library classes?
For instance: If I have a function or two that is used globally, should that be contained in a library?
Secondly, I have a certain code that checks session data for ACL related information. Should I put the if statement to return certain data in my view file, or in a function in a controller class ?
For instance, in the view I could have:
Code:
<?php if ($this->session->userdata('access_lvl') == 1) : ?>
<!-- Some code here -->
<?php else : ?>
<!-- Some different code here -->
<?php endif; ?>
Or should I have the controller call different view files for different cases like so:
Code:
function check_access_level() {
if ($this->session->userdata('access_lvl') == 1) {
$this->load->view('access1');
else {
$this->load->view('access2');
}
}
Essentially both do the same thing right? So is there a reason I should be using one or the other? Or are both okay?