[eluser]wild thing[/eluser]
Hi,
I had actually posted the entire source code with a link, but apologies, I guess it wasn't clear. I am now attaching the source with the post:
Code:
/*
General configuration:
config.php - $autoload['libraries'] = array('database', 'session');
routes.php - $route['default_controller'] = "blahg";
constants.php - define('WEBSITE_TITLE', 'Blahg v0.1a');
database.php - db settings (username, db, password)
*/
//Controller Code - /application/controllers/blahg.php
<?php
class Blahg extends Controller {
function Blahg() {
parent::Controller();
}
function index() {
//$data['page_title'] = WEBSITE_TITLE.' | Blahg List';
$this->load->model('Posts_model', 'posts');
if($posts)
echo "Success";
else
echo "Failure";
//$data['posts'] = $Posts_model->get_posts(10);
//$this->load->view('blahg_view', $data);
}
}
?>
//Model Code - /application/models/posts_model.php
<?php
class Posts_model extends Model {
private $title = '';
private $content = '';
private $added = '';
private $updated = '';
function Posts_model() {
parent::Model();
}
function get_posts($number_of_posts) {
$query = $this->db->get('posts', $number_of_posts);
return $query->result();
}
}
?>
//View Code - /application/views/blahg_view.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<link href="css/core.css" rel="stylesheet" type="text/css" />
<link href="css/posts.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $page_title; ?></title>
</head>
<body>
<!-- Blog Entries List -->
<?php
//Load Blahg entries
foreach($posts as $post)
{
?>
<div>
<h3><?php echo $post['title'] ?></h3>
<div class="date">
added <?php echo $post['added']; ?>
<?php
if($post['updated'])
{
?>
| updated <?php echo $post['updated']; ?>
<?php
}
?>
</div>
</div>
<?php
}
?>
</body>
</html>