Skip to content

Commit

Permalink
Getting the main blog page up and running.
Browse files Browse the repository at this point in the history
  • Loading branch information
daveWid committed Dec 7, 2011
1 parent bb772a1 commit ded46a2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 51 deletions.
39 changes: 1 addition & 38 deletions classes/controller/soapbox.php
@@ -1,40 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
/**
* This is a very basic Soapbox controller.
*
* It is for demonstration purposes only. Please move this logic into
* real controllers on your site.
*
* (note) Update your Soapbox config when you move this logic!!
*
* @package Soapbox
* @author Dave Widmer
* @copyright 2011 © Dave Widmer
*/
class Controller_Soapbox extends Controller
{
/**
* The home page
*/
public function action_index()
{
die('This is where your homepage will go (more than likely a list of posts');
}

/**
* The categories listing
*/
public function action_category()
{
die('This is where you will show a list of posts with the given category');
}

/**
* A single post
*/
public function action_single()
{
die('Here is where you will show a single post');
}

}
class Controller_Soapbox extends Soapbox_Controller{}
55 changes: 55 additions & 0 deletions classes/soapbox/controller.php
@@ -0,0 +1,55 @@
<?php defined('SYSPATH') or die('No direct script access.');
/**
* The Soapbox Controller handles the displaying of a list of posts, categores
* and a single post
*
* @package Soapbox
* @author Dave Widmer <dave@davewidmer.net>
* @copyright 2011 © Dave Widmer
*/
class Soapbox_Controller extends Controller_Template
{
/**
* @var array An array of configuration values
*/
protected $_config;

/**
* Get the configuration
*/
public function before()
{
$this->_config = Kohana::$config->load('soapbox');
return parent::before();
}

/**
* Views the current posts.
*/
public function action_index()
{
$page = $this->request->param('page', 1);

$this->template->title = $this->_config['title'];
$this->template->content = View::factory('soapbox/list')->set(array(
'posts' => Model::factory('post')->fetch($this->_config['per_page'], $page),
));
}

/**
* Lists the posts in a given category
*/
public function action_category()
{
die('This is where you will show a list of posts with the given category');
}

/**
* View a single post
*/
public function action_post()
{
die('Here is where you will show a single post');
}

}
4 changes: 2 additions & 2 deletions views/soapbox/list.php
@@ -1,9 +1,9 @@
<?php if (isset($title)): ?>
<h1><?php echo $title; ?>
<h1><?php echo $title; ?></h1>
<?php endif; ?>

<?php
foreach ($posts as $post)
{
echo View::factory('soapbox/single')->set((array) $post);
echo View::factory('soapbox/post')->set((array) $post);
}
13 changes: 2 additions & 11 deletions views/soapbox/single.php → views/soapbox/post.php
@@ -1,16 +1,7 @@
<?php
/*
public 'post_id'
public 'title'
public 'slug'
public 'contents'
public 'posted_date'
*/
?>

<article>
<h2><?php echo $title; ?></h2>
<div class="date">Posted: <?php echo Date::formatted_time($posted_date, "l F jS, Y"); ?></div>

<div class="categories"><?php echo Model_Post_Category::link(Model_Post_Category::post_categories($post_id)); ?></div>

<div class="contents"><?php echo $contents; ?></div>
</article>

0 comments on commit ded46a2

Please sign in to comment.