Skip to content

Commit

Permalink
handling the saving and display of dates on articles
Browse files Browse the repository at this point in the history
Conflicts:

	app/templates/posts/single.tpl
  • Loading branch information
spf13 committed Jan 10, 2012
1 parent d51557c commit 9a3d459
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion app/routes/articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ function __construct() {
$article->author = $s->request()->post('author');
$article->tags = $trim_array(explode(",", $s->request()->post('tags')));
$article->categories = $trim_array(explode(",", $s->request()->post('categories')));
$article->created_at = new MongoDate(strtotime($s->request()->post('created_at')));
$created_at = $s->request()->post('created_at');
if(empty($created_at)) {
$article->created_at = new MongoDate();
} else {
$article->created_at = new MongoDate(strtotime($created_at));
}

$s->db->articles->save($article);
$s->redirect($s->urlFor($prefix));
Expand Down
2 changes: 1 addition & 1 deletion app/templates/articles/edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{inputbox name=slug value=$article.slug hint="url key for this article"}
{inputbox name=tags value=$article.tags|implode hint="comma separated list"}
{inputbox name=categories value=$article.categories|implode hint="comma separated list"}
{inputbox name=created_at value=$article.created_at|date_format:"%B %e, %Y %H:%M:%S" hint="leave blank for now()"}
{inputbox name=created_at value=$article.created_at->sec|date_format:"%B %e, %Y %H:%M:%S" hint="leave blank for now()"}

<label for="author">Author
<span class="small">Author of the post</span>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/articles/list.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{foreach from=$articles item=article}
<tr>
<td>{$article.title}</td>
<td>{$article.created_at|date_format}</td>
<td>{$article.created_at->sec|date_format}</td>
<td><a href="{slimurl name='article_edit' values=$article}">Edit</a></td>
<td><a href="{slimurl name="article_delete" values=$article}">Delete</a></td>
</tr>
Expand Down

0 comments on commit 9a3d459

Please sign in to comment.