[eluser]Unknown[/eluser]
Is it okay to have some html tags in codeigniter controller. Sometimes i found it difficult to decide that should i move logic into view or html into controller.
Suppose i want to show a textarea for only profile owner and administrator this can be done by two way(as far as i know).
1. Putting more php in view like
Code:
if($this->session->username() == $user || $this->session->username() == $administrator){
echo '<textarea></textarea>';
}
2.Putting html tags in controller like
Code:
$data['textarea'] = ""; if($this->session->username() == $user || $this->session->username() == $administrator){
$data['textarea'] = '<textarea></textarea>';
}
$this->load->view('example', $data);
There are some other many cases where i found it almost impossible or v difficult to have separate html tags from controller like here i want to show menu with submenu also so we have to run two foreach loop one for main menu and the second one for submenu which only run if main menu has submenu.