Welcome Guest, Not a member yet? Register   Sign In
Database Powered Template Parser Variable Pairs?
#1

[eluser]ShoeLace1291[/eluser]
I have a list of news articles that I want to be able to parse with database queries. I read the guide on the template parser class and the variable pairs example that they used is pretty much what I want to do. The only thing is that I really can't figure out how to make it database powered.
Code:
$query = $this->db->query("SELECT * FROM news ORDER BY id DESC LIMIT 10");
foreach($query->result() as $news){
  $this->news->article($news->id);
   $data = array(
                 'ID' => $news->id,
                 'TITLE' => $this->news->title,
                 'BODY' => $this->news->body
                 );
}

$this->parser->parse('index_body.tpl', $data);
The reason I want to do this is because it makes templating easier and it also makes it easier to execute more complicated scripts in the model without having to do it in the controller.


Messages In This Thread
Database Powered Template Parser Variable Pairs? - by El Forum - 08-31-2010, 06:57 PM
Database Powered Template Parser Variable Pairs? - by El Forum - 08-31-2010, 09:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB