Skip to content

Commit

Permalink
Added thumbnail sidebar embed to blog app
Browse files Browse the repository at this point in the history
  • Loading branch information
jbroadway committed Apr 4, 2017
1 parent 4a51067 commit ee3653c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/blog/conf/embed.php
Expand Up @@ -24,6 +24,11 @@
dates[require] = "apps/blog/lib/Functions.php"
dates[callback] = "blog_yes_no"
[blog/thumbnail-sidebar]
label = "Blog: Thumbnail Sidebar"
icon = rss
[blog/bymonth]
label = "Blog: Headlines by Month"
Expand Down
21 changes: 21 additions & 0 deletions apps/blog/handlers/thumbnail-sidebar.php
@@ -0,0 +1,21 @@
<?php

/**
* Displays the latest blog posts with feature thumbnails for the
* top three.
*/

require_once ('apps/blog/lib/Filters.php');

$limit = 8;

$posts = blog\Post::query (array ('id', 'ts', 'title', 'thumbnail'))
->where ('published', 'yes')
->order ('ts desc')
->fetch_orig ($limit);

$page->add_script ('/apps/blog/css/related.css');

echo $tpl->render ('blog/thumbnail-sidebar', array (
'posts' => $posts
));
29 changes: 29 additions & 0 deletions apps/blog/views/thumbnail-sidebar.html
@@ -0,0 +1,29 @@
{! admin/util/dates !}

{% foreach posts as n, post %}
{% if n < 3 %}
<div class="blog-related-post item">
<div class="thumbnail-wrapper">
<a href="/blog/post/{{post->id}}/{{post->title|URLify::filter}}">
<div class="thumbnail"
{% if post->thumbnail != '' %}
style="background-image: url('/{{post->thumbnail|Image::resize (%s, 400, 300, 'cover', 'ext')}}')"
{% end %}
></div>
</a>
</div>
<div class="item-info">
<h4><a href="/blog/post/{{post->id}}/{{post->title|URLify::filter}}">{{post->title}}</a></h4>
<p>{{post->ts|I18n::short_date_year}}</p>
</div>
</div>
{% end %}
{% end %}

<ul class="blog-headlines">
{% foreach posts as n, post %}
{% if n >= 3 %}
<li>{{ post->ts|I18n::short_date }} <a href="/blog/post/{{ post->id }}/{{ post->title|URLify::filter }}">{{ post->title }}</a></li>
{% end %}
{% end %}
</ul>

0 comments on commit ee3653c

Please sign in to comment.