There are several ways to avoid that solution, but it really depends on the scale of issue.
A better solution could possibly be something like the follwoing.
View
<?php echo $conditional_html; ?>
Controller
switch($pageID)
{
case 1:
$data['conditional_html'] = $this->load->view('the_first_id_html', TRUE);
break;
case 4:
case 7:
case 8:
$data['conditional_html'] = $this->load->view('some_special_html', TRUE);
break;
case 13:
case 18:
$data['conditional_html'] = $this->load->view('the_secret_menu_html', TRUE);
break;
default:
$data['conditional_html'] = $this->load->view('the_default_html', TRUE);
}
$this->load->vars($data);
If you don't mind loading views within your views, another simpler way of doing it could be like this:
View
<?php $this->load->view($conditional_html); ?>
Controller
switch($pageID)
{
case 1:
$data['conditional_html'] = 'the_first_id_html';
break;
case 4:
case 7:
case 8:
$data['conditional_html'] = 'some_special_html';
break;
case 13:
case 18:
$data['conditional_html'] = 'the_secret_menu_html';
break;
default:
$data['conditional_html'] = 'the_default_html':
}
$this->load->vars($data);
In the end, you can do this in many different ways, but I hope this could shed some light on some alternative ways to do it.