[eluser]JayArias[/eluser]
Ok, so I finall got around to understanding the template library. But i've still got some problems with my code.
Code:
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index()
{
$this->template->set_template('default');
$this->template->write('title', "Default");
$this->template->render();
}
}
to show
Code:
$this->catalog->getLatest();
I have to place it in the view file or template.php file.
what I want to do is the following.
Code:
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index()
{
$this->template->set_template('default');
$this->template->write('title', "Default");
$this->template->write('content', $this->catalog->getLatest());
$this->template->render();
}
}
Yes, the code works but it doesn't appear in the correct spot it appears uptop before any of the code.
Here is my Model "Catalog"
Code:
<?php
Class catalog extends Model{
function catalog()
{
parent::Model();
$this->load->database('default');
}
function getLatest()
{
$query = $this->db->query("SELECT * FROM `products` WHERE `aprooved` = '1'");
foreach($query->result() as $product)
{
echo "<ul>";
echo "<li><a >category."/".$product->product_title."'><strong>".$product->product_title."</strong></a><br>";
echo "<small> Submitted by <a >author."'>".$product->author."</a></small><br>";
echo "<a >category."/".$product->product_title."'><img >product_thumbnail."'><a/></li>";
echo "</ul>";
}
}
}
Please help.