[eluser]xwero[/eluser]
You can create a helper
Code:
function limit_text($text,$limit,$arraykey='')
{
if(is_string($text))
{
return substr($text,0,$limit);
}
if(is_array($text) && $arraykey != '')
{
if(array_key_exists($arraykey,$text)) // for single dimension array
{
$text[$arraykey] = substr($text[$arraykey],0,$limit);
return $text;
}
else // two dimensional array (database result)
{
foreach($text as $key => $item)
{
$text[$i][$arraykey] = substr($item[$arraykey],0,$limit);
}
}
}
}
You can add the object branch if you want.
Then in the controller you can do
Code:
function index()
{
$data['heading'] = 'projects';
$this->load->model('Proj');
$this->load->helper('the helper name you put the function in');
$data['query'] = limit_text($this->Proj->get_list(),150,'content'); // in the get_list method you need to use result_array if you don't add a object branch in the function
$data['page'] = $this->config->item('FAL_template_dir').'template/projects';
$this->load->vars($data);
$this->load->view($this->_container);
}