Correct if Syntax
Your if-statement syntax is a bit off. You can use either:
if (condition) { // do a } else { // do b }
or
if (condition) : // do a else : // do b endif;
It seems you transfer the end of the last to the first.
Use ternary operator in title
Once you make this change, your title can be printed as easily as:
<title><?php echo isset($title) ? $title : 'Default Title' ; ?></title>
Alternative view Download
Another method of loading views is to work with a single template file:
$data['title'] = 'Foo Bar'; $data['content'] = 'indexPage'; $this->load->view('template', $data);
This loads the template.php file as your view. In this file you download the following parts:
<?php $this->load->view("_header"); ?> <?php $this->load->view($content); ?> <?php $this->load->view("_footer"); ?>
This is not necessary, but it can help you keep the brevity in your controller.
source share