Profile, selecting only three posts from different category

Discuss news styles, css code, and other Coranto customizations in here...the possibilities are endless, so have at it!

Moderator: Spunkmeyer

Profile, selecting only three posts from different category

Postby futureman0 » Mon Sep 11, 2006 2:04 am

Hello -

I'm trying to do the following. I have a main profile called news that pulls posts from several categories. Is there a way to only say select three of each category to display? Thanks for the help.
futureman0
 
Posts: 2
Joined: Wed Aug 23, 2006 9:33 pm

Postby Dale Ray » Mon Sep 11, 2006 5:05 am

Code: Select all
<PerlCode>
$show = 1;
if ( isNewCategory() ) {
$count = 1;
    } else {
$count++;
}
if ($count > 3) {
$show = 0;
}
if ($show) {
</PerlCode>
<If: Field: count == 1><Field: Category></If>
<Field: Date> - <Field: Hour>:<Field: Minute>:<Field: Second> <Field: AMPM>
<Field: Subject>
<Field: Text>
</If>


Sort by category using the SortOrders addon.

This:
Code: Select all
<If: Field: count == 1><Field: Category></If>

will cause the category name to only print when a new category starts.

Using

if ($show) {

before the closing </PerlCode> tag eliminates a bunch of whitespace that happens if you use:

<If: Field: show>

after the closing </PerlCode> tag.

This should give you the three newest items in each category if all of your filter settings for the profile are empty.
Dale Ray
User avatar
Dale Ray
 
Posts: 1001
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana

Postby Parahead » Mon Sep 11, 2006 6:10 pm

Dale Ray wrote:This should give you the three newest items in each category if all of your filter settings for the profile are empty.
Or if the sorting by Category is not wanted, one could use:

Code: Select all
<PerlCode>
$countitems{"$ProfileName-$Category"}++;

if($countitems{"$ProfileName-$Category"} > 3) {
    next;
}</PerlCode>
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Dale Ray » Tue Sep 12, 2006 5:43 am

Parahead,

What's wrong with using 20 or 30 lines of code when 3 will do? :pray: I bow to the master.

I am going to file this one away for future reference.
Dale Ray
User avatar
Dale Ray
 
Posts: 1001
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana

Postby Parahead » Thu Sep 14, 2006 6:06 pm

No hint intended, really. Your solution do provide extra features which mine doesn't, hence I could slim it...
:cheers:
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden


Return to Customization

Who is online

Users browsing this forum: No registered users and 1 guest

cron