[eluser]ashbyrich[/eluser]
I am trying to be a little bit more structured/keep garbage out of my views having been impressed by Freakauthor Light.
Crudely I want to create a summary list of the first 150 words of my 'content' field in the database. I could do something with php
Code:
substr(<?=$item->content ?>,0 ,150)
but would prefer a solution in my Model....
Controller (excerpt)
Code:
function index()
{
$data['heading'] = 'projects';
$this->load->model('Proj');
$data['query'] = $this->Proj->get_list();
$data['page'] = $this->config->item('FAL_template_dir').'template/projects';
$this->load->vars($data);
$this->load->view($this->_container);
}
Model (excerpt)
Code:
function get_list()
{
$query = $this->db->get('projects');
return $query->result();
}
View (excerpt)
Code:
<?php foreach($query as $item): ?>
<p> <?=$item->id ?> <?=$item->content ?></p>
<?php endforeach; ?>