public function whatever()
{
$data = new stdClass(); // initialize $data
$tips = $this->getTips();
if ($this->form_validation->run() === false) {
if ($this->User_model->isLogged()) {
$user = $this->User_model->getUser($_SESSION['id']);
}
$data->tips = $tips;
$data->name = isset($user) && isset($user->username) ? $user->username : "Guest";
$this->loadViews('base/index', 'sidebar', $data);
} else {
// ...
}
}
private function getTips()
{
return array(
// ...
);
}
private function loadViews($contentView, $sidebarView = null, $data = array())
{
$this->load->view('header', $data);
$this->load->view($contentView, $data);
if ( ! empty($sidebarView)) {
$this->load->view($sidebarView, $data);
}
$this->load->view('footer', $data);
}