The Properties/Templates of categories plugin

Creating and modifying plugins.
Post Reply
AFC_North
Regular
Posts: 31
Joined: Fri Nov 30, 2007 12:56 am

The Properties/Templates of categories plugin

Post by AFC_North »

Hi! It's been a couple of years since I posted here, but I've found Serendipity to be really helpful for organizing my football website at http://www.afc-north.com.

Recently, I've been trying to see what I can do with the ability to give different categories of posts different templates. I created a "games" category for posts that show the scoreboard for a specific game, with the idea that people can discuss the game before, while, and after it takes place by posting comments.

For this reason, I decided that I wanted future posts in the "games" category to be visible, but not future posts in other categories.

It looks like I ought to be able to accomplish this with the "Properties/Templates of categories" plugin. After I installed it, the "edit" page for each category has an option labeled "Show future entries." But setting that to "Yes" didn't make future "games" entries visible. I was only able to make them visible by adjusting the "Configuration" settings for the whole board, which of course made all future entries visible.

Is there a bug in the code somewhere, or a version update I need?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: The Properties/Templates of categories plugin

Post by garvinhicking »

Hi!

This switch is only meant for the category-based views, so if you view blog entries after clicking on your category. It does NOT apply to the entry's category heritage.

The global option defines how entries are shown on your homepage; the category-specific options only for their views. So you can only make games future entrie svisibile inside the category, not on the homepage. On the homepage only, if you show ALL future entries.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
AFC_North
Regular
Posts: 31
Joined: Fri Nov 30, 2007 12:56 am

Re: The Properties/Templates of categories plugin

Post by AFC_North »

Okay, thanks. It looks like that wasn't something the software was intended to do.

In a similar vein, I was wondering if it's possible to make posts appear differently on the front page based on their category. I can use the plugin to create a different template for a category, but that only affects how posts look when a user clicks on an individual post or views all posts in that specific category.

Can I use Smarty IF statements in the "entries.tpl" file to get posts in different categories to look different (a simple example would be giving all "game" posts a different font color from the others) or contain different things? Something like this:

{if $entry_category == "game"}
...
{/if}

I had a little bit of success getting "game" posts not to include the poster name and time (it saves space), but it's not quite working right-- it's applying the same format to every post based on whatever category the top post has instead of applying it to each post individually.

(I thought I posted this yesterday, but it's not showing up today, so forgive me if this ends up being a double post.)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: The Properties/Templates of categories plugin

Post by garvinhicking »

Hi!

Yes, inside entries.tpl you could output all category classes, for example inside the <div> for the entry, so that you can use CSS to change the look of those containers.

An example:

Code: Select all

<div class="serendipity_entry serendipity_entry_author_{$entry.author|@makeFilename} {if $entry.is_entry_owner}serendipity_entry_author_self{/if}">
can be modified to:

Code: Select all

<div class="serendipity_entry serendipity_entry_author_{$entry.author|@makeFilename} {if $entry.is_entry_owner}serendipity_entry_author_self{/if} {foreach from=$entry.categories item="entry_category"}entrycategory_{$entry_category.category_name} {/foreach}">
and then you could use this CSS:

Code: Select all

.entrycategory_News {
border: 1px solid red
}

.entrycategory_Sports {
border: 1px solid blue
}
...
HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply