Skip to content

Instantly share code, notes, and snippets.

@jbroadway
Created April 8, 2012 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbroadway/2339929 to your computer and use it in GitHub Desktop.
Save jbroadway/2339929 to your computer and use it in GitHub Desktop.
Custom handler for displaying latest blog headlines with dates
; <?php /*
[myapp/headlines]
label = "My App: Latest Posts"
; */ ?>
<?php
require_once ('apps/blog/lib/Filters.php');
$posts = blog\Post::query (array ('id', 'ts', 'title'))
->where ('published', 'yes')
->order ('ts desc')
->fetch_orig (10);
echo $tpl->render ('myapp/headlines', array (
'posts' => $posts
));
?>
<ul>
{% foreach posts %}
<li>
{{ loop_value->ts|date ('M j', strtotime (%s)) }}
<a href="/blog/post/{{ loop_value->id }}/{{ loop_value->title|blog_filter_title }}">{{ loop_value->title }}</a>
</li>
{% end %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment