Welcome Guest, Not a member yet? Register   Sign In
Help required getting logic out of View and in to Model
#1

[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> &lt;?=$item->id ?&gt; &lt;?=$item->content ?&gt;</p>

&lt;?php endforeach; ?&gt;


Messages In This Thread
Help required getting logic out of View and in to Model - by El Forum - 03-06-2008, 05:40 AM
Help required getting logic out of View and in to Model - by El Forum - 03-06-2008, 05:58 AM
Help required getting logic out of View and in to Model - by El Forum - 03-06-2008, 06:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB