In CodeIgniter, or core PHP; is there an equivalent of Rails\'s view partials and templates?
A partial would let me render another view fragment inside my view. I co
this is essentially what I use:
function render_partial($file, $data = false, $locals = array()) {
$contents = '';
foreach($locals AS $key => $value) {
${$key} = $value;
}
${$name . '_counter'} = 0;
foreach($data AS $object) {
${$name} = $object;
ob_start();
include $file;
$contents .= ob_get_contents();
ob_end_clean();
${$name . '_counter'}++;
}
return $contents;
}
this allows you to call something like:
render_partial('/path/to/person.phtml', array('dennis', 'dee', 'mac', 'charlie'), array('say_hello' => true));
and in /path/to/person.phtml have:
= if($say_hello) { "Hello, " } ?>= $person ?> (= $person_counter ?>)
this is some magic going on though that may help you get a better picture of what's going on. full file: view.class.php