[eluser]Mr. Pickle[/eluser]
Is it allowed to access a model from a helper? And if so, how should you set this up for an own helper file?
In my case some views have an id of a record. I'd like to have this converted to a name with a helper function allowing me to run a function like:
Excerpt of viewfile code
Code:
<?php echo get_record_name($id); ?>
My helper file has:
Code:
/**
*
* Convert an id to a name
*
* @access public
* @param integer
* @return string
*/
if ( ! function_exists('get_record_name')) {
function get_record_name($id) {
// I think I have to do something here to get access to models
$name = $this->record_model->get_name_by_id($id);
return $name;
}
}
I seem to have no connection to my models in helpers. I understand that helpers should be simple procedural and independent so I like to hear your opinions on if this is possible and do-able.