Help with a Theme

51 views
Skip to first unread message

Kamran

unread,
Feb 23, 2013, 10:15:08 AM2/23/13
to habari...@googlegroups.com
Hi everybody,

I am trying to build a theme similar to omgubuntu. On the homepage an image is shown for every post either extracted from the post or another image. Each post also has a type like news, howto or editorial. So how would i add a separate image with a post to be used as a thumbnail and  how to add the types. Should i add Content types or something else? 

Thank You very much.
Regards,
kamran

Owen Winkler

unread,
Feb 23, 2013, 12:19:17 PM2/23/13
to habari...@googlegroups.com
On 2/23/2013 10:15 AM, Kamran wrote:
>
> I am trying to build a theme similar to omgubuntu
> <http://www.omgubuntu.co.uk/>. On the homepage an image is shown for
> every post either extracted from the post or another image. Each post
> also has a type like news, howto or editorial. So how would i add
> a separate image with a post to be used as a thumbnail and how to add
> the types. Should i add Content types or something else?

I think the type of thing you're looking for is the theme I've built for
redalt.com: https://github.com/ringmaster/heavy

This theme adds a field to every entry that can be assigned an image
from the media browser. That image can in turn be used by the theme
when an image is required.

Assigning the tag "headline" to a post promotes it into the "headlines"
preset, which is displayed by a custom block that the theme provides. I
dropped that block into the top_content area of the theme (only in the
"Homepage" scope, so it only appears on the home page), and posts with
the "headline" tag appear in that area with the image.

You should be able to extend this idea to do different types of posts,
like editorial, howto, or news.

Also, you could instead do something like what we did for the
twentythirteen theme clone:
https://github.com/ringmaster/twentythirteen/blob/master/theme.php

This theme isn't as well documented, but it has some interesting
component parts that might be useful for what you're building. The
useful parts are:

* The get_action_form_publish_entry() method, which adds a list of
potential "formats" to the entry editing form.
* The filter_content_type() method, which augments the fallback template
list for any post by adding its saved format to the template name.
* The separate templates for each of the formats named
entry.{format}.php, each of which being used for its respective format type.

Using this system with some tweaks including an additional context
parameter -- within twetythirteen's home.php file, you'll see a call to
$theme->content($post), which you'd change to $theme->content($post,
'context') -- you can gain access to templates like
entry.{format}.{context}.php, so that your headline area posts could use
a different template than your main content area posts. Just a thought.

Hope that's helpful.

Owen

Kamran

unread,
Feb 23, 2013, 2:20:15 PM2/23/13
to habari...@googlegroups.com
Thats more than helpful. Thanks Owen.

Kamran

unread,
Mar 1, 2013, 7:07:05 AM3/1/13
to habari...@googlegroups.com
Hi Owen

How can i retrieve top posts on the basis of no of comments or most viewed?

Thanks

Konzertheld

unread,
Mar 5, 2013, 8:28:19 AM3/5/13
to habari...@googlegroups.com
Hi Kamran,

Habari does not track post views itself. There are plugins like https://github.com/habari-extras/relativelypopular - you might want to have a look at them. Feel free to extend them to your needs.

You can get the comments and with that the number of comments per post by Comments::get_by_id($post_id) for example. You would have to get the comment number for all posts and determine the highest numbers yourself. That could be done once, stored in a postinfo and then updated every time someone posts a comment. There might be an easier way with custom database queries, but I do not know about that.

Christian
Reply all
Reply to author
Forward
0 new messages