News Page: One List or Three?

4 posts by 2 authors in: Forums > CMS Builder
Last Post: June 10, 2010   (RSS)

Re: [Perchpole] News Page: One List or Three?

By Jason - June 10, 2010

Hi,

I think the easiest way to accomplish this would be to select all of the stories first. Then have a counter that get's incremented after each story is outputted. You can then do your output with a simple if statement. Something similar to this:

<?php if($count==1): ?>
*OUTPUT TOP STORY*
<?php elseif($count>1 && $count<4): ?>
*OUTPUT FOR STORY 2 AND 3 *
<?php else: ?>
*OUTPUT FOR EVERYTHING ELSE*
<?php endif ?>
<?php $count++; ?>


This would work if you set $count=1 before you started your foreach loop and incremented it (<?php $count++?> )at the end of the loop.

Hope this points you in the right direction. If you run into any issues, please attach the .php file you're working with.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] News Page: One List or Three?

By Perchpole - June 10, 2010

Hi, Jason -

Thanks for that. The counter is such a simple mechanism. It would be rude not to use it more often!

Can you think of any more tips or useful ways in which we might employ it?

:0)

Perch

Re: [Perchpole] News Page: One List or Three?

By Jason - June 10, 2010

Hi Perch,

Glad that's working for you.

The counter is great for (other than just counter), any situation where you need to know where you are in a list.

A lot of people use it to break up content at certain intervals (ie, make a new column after every X number of records).
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/