Prevent Same Page from Showing Twice

Permalink
This is related to the same issue I posted here:

http://www.concrete5.org/community/forums/customizing_c5/show-not-f...

This is on the same website. I have three "featured" news stories across the top of the homepage, and then underneat that another story.

Both are separate page lists.

What's happening now is that my three featured stories are displaying just fine, but in order to keep one of those three stories from also displaying in the second block, I have that template to look for pages that are NOT featured. This works okay in theory, except it ends up skipping several other stories that were featured at one point but no longer show up in the three featured positions.

So what I get is a story that's several days old and is not featured.

Bascially, I want only stories from the current day (we post dozens of stories each day). Three featured, one not featured.

Any ideas?

leinteractive
 
glockops replied on at Permalink Reply
glockops
Edit...

Ok, so your concern is that old, previously highlighted featured stories are not displaying in the #4 position?

You want three of the latest, featured stories highlighted in a special manner, and then a forth story (which may or may not be featured) to appear in a different manner... correct?

1: [Highlighted Feature]
2: [Highlighted Feature]
3: [Highlighted Feature]
4: [Non-highlighted article (may/may not be featured)]

Scenerios,
You just posted four featured stories back to back, they appear like
1: [Highlighted Feature #4]
2: [Highlighted Feature #3]
3: [Highlighted Feature #2]
4: [Feature #1 (oldest)]

You then add a non-featured story, the output is now
1: [Highlighted Feature #4]
2: [Highlighted Feature #3]
3: [Highlighted Feature #2]
4: [Non-feature (newest)]

You then add a new featured story (#5), the output is now
1: [Highlighted Feature #5 (newest)]
2: [Highlighted Feature #4]
3: [Highlighted Feature #3]
4: [Non-feature (2nd newest)]

Is that what you're going for?
leinteractive replied on at Permalink Reply
leinteractive
That is exactly correct!

I was able to "fix this by, instead of using two different Page Lists, I combined all the functionality into one page list and set it to display 4 items.

I created an index number in my php file to count up to 3, so I can style my first three items as Highlights and then anything after that will be displayed normally.

I'm not sure if this was the best way or not, but it seemed to do the trick.

What did you have in mind?

EDIT:
After reading through your post again, the 2nd Scnario you provide is not possible with my setup, as my setup will only show Featured Stories.

I want to show three featured and then one other story that may or may not be featured, but is the latest story posted.
glockops replied on at Permalink Best Answer Reply
glockops
The solution that you've come up with is one I was going to suggest. However if I understand your explanation correctly, you may have non-featured stories highlighted, as the first three pages will be the last three pages added to the system (if you've used newest first sorting).

If you want your highlighted stories to be exclusively featured stories, then you'll need to separate the pages (either $pages or $cArray, can't remember) into two arrays, one featured (with a maximum of 3 values) and the other with everything else.
// Untested/Psuedocode because I'm feeling lazy
$highlighted = array();
$others = array();
foreach($pages as $p) {
if($p->is_featured() && count($highlighted < 3)) {
$highlighted[] = $p;
} else {
$others[] = $p
}


Ideally, you'd do this in the controller, but you can get away with putting it in the view.php

Now you have two arrays that you can output appropriately.

It's totally possible that highlighted array may have 0, 1, 2, or 3 values stored in it. But $highlighted + $others will equal the number of items you've set the page list to display. So whatever design you come up with should be able to handle those conditions.

So say, you always want to make sure you have 3 featured stories, then you might want to increase the number of pages returned to 10, to give you some padding if you occasionally post a lot of non-featured stories. If you still only want to display 4, you could work that out in your view, where you don't loop through the entire $other array - or get extra complex where you count the $highlighted array and subtract it from the total number you want displayed and only loop through the $other array that many times.