Aggregating other category entries on a category index.tpl

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
tpost
Regular
Posts: 77
Joined: Fri Sep 21, 2007 1:45 am

Aggregating other category entries on a category index.tpl

Post by tpost »

Hi everyone,

I have a main category called "news" and a few sub-categories called "events" and "press".

What I want to do on the "news" category index page is aggregate the last 5 entries for each sub-category.

eg.

Code: Select all

<h1>News category</h1>
<p>Some description about the category</p>

<h2>Last 5 events</h2>
-Event 1 title
--Event 1 teaser

-Event 2 title
--Event 2 teaser

-Event 3 title
--Event 3 teaser

-Event 4 title
--Event 4 teaser

-Event 5 title
--Event 5 teaser
-Event 1 title
--Event 1 teaser

<h2>Last 5 press releases</h2>
-Press 1 title
--Press 1 teaser

-Press 2 title
--Press 2 teaser

-Press 3 title
--Press 3 teaser

-Press 4 title
--Press 4 teaser

-Press 5 title
--Press 5 teaser
I came across yellowled's Mimbo port and noticed it has almost exactly what I'm looking for!

The only problem is I have installed the "Start Page Category" plugin and the "Properties / Templates of categories" plugin, which doesn't exactly gel with the code yellowled uses for his Mimbo port.

The "news" category I have is not the Start Page category.

Is there some way I can achieve what I want while keeping the "Start Page Category" and "Properties / Templates of categories" plugins enabled?

Thanks for reading!
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Aggregating other category entries on a category index.t

Post by garvinhicking »

Hi!

So you mean that a staticpage is the page where you want your aggregated entries to show?

That would make things actually quite easy.

You have two options:

1. Install and use the smartymarkup plugin. Now you can put the {serendipity_fetchPrintEntries} (see technical docs on www.s9y.org) smarty call in your staticpage and fetch the entries from your sub-categories and render them with a custom template

2. Create a distinct staticpage articletype with a custom template. You can put the {serendipity_fetchPrintEntries} call into this custom template, and then assign your startpage to this staticpage articletype.

If you want to do that unrelated to your staticpage, you can always edit the index.tpl template file of your template, and put those smarty calls in there, at the place you want. You can check the various smarty variagbles (also tech docs) to make sure that they are only shown for a specific category, on the startpage or whatever...

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/
tpost
Regular
Posts: 77
Joined: Fri Sep 21, 2007 1:45 am

Post by tpost »

Hi Garvin,

Thanks for the info!

After looking at yellowled's Mimbo port again, I found out where I was going wrong!

He used the attribute {if $view == start} in order to find out if it was the start page, whereas the category I wanted to apply the aggregating feature was a secondary category.
Post Reply