Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Getting the main blog page up and running.
- Loading branch information
Showing
4 changed files
with
60 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |