[eluser]tomcode[/eluser]
Sorry, did show my code example too simplictic. I'm passing information to the controller.
Each view file contains different parameters, so I cannot set the values in the controller.
The main idea is to keep the data out of the controller.
Code:
function insert_code($file = FALSE)
{
if ($file)
{
$open = "<?php ";
$file .= '.code.php';
$code = $open .file_get_contents(APPPATH.'views/code/'.$file);
$coloredstring =highlight_string($code,TRUE);
$results[] = '<div class="code">';
$results[] = str_replace('<?php ','',$coloredstring);
$results[] ='</div>';
return implode("\r\n", $results);
}
}
And in the fragment views i have
file 1
Code:
<?=$this->insert_code('some_file_name');?>
file 2
Code:
<?=$this->insert_code('some_other_file_name');?>
I also call the function several times per fragment view.