Featured story/top news items

6 posts by 3 authors in: Forums > CMS Builder
Last Post: September 29, 2015   (RSS)

I'm trying to set up my homepage so it has 3 top stories or news items. The first one has a layout of it's own with a larger photo, then the other two stories appear below it. You can see the layout here:

http://www.polkcountynewspaper.com/new2/index.php

I already added "feature_1, feature_2, feature_3" as a new field in the Section Editor area, but I'm not great at the code and fields. How do I tell it to place feature_1 in the top position (if the box is checked for that story) and then feature_2 goes in the next slot, etc?

I figured it's probably if "feature_1" is checked, then display the story.

If feature_2 is checked, then put that story here... etc. But I don't know how to write that snippet of code.

Your help would be greatly appreciated! Thanks!!

By Daryl - September 23, 2015

Hi rlindauer,

I figured it's probably if "feature_1" is checked, then display the story.

- Yes, that is one of many ways to do it. You need to loop through the news records until you find the record with featured_* checked, and then display the record. But you'll need to do the loop 2 or 3 times.
For example:

<!--For the 1st featured news-->
<?php
foreach ($newsRecords as $record){
  if (!$record['featured_1']) { continue; } // continue looping if featured_1 is not checked
  ?>
  your html code here + record's contents
  <?php
}
?>

<!--For the next 2 featured news-->
<?php
foreach ($newsRecords as $record){
  if (!$record['featured_2'] AND !$record['featured_3']) { continue; }
  ?>
  your html code here + record's contents
  <?php
}
?>

Hope that helps!

Cheers,

Daryl Maximo
PHP Programmer - interactivetools.com

Thanks for your help! We're on the right track! Except now I'm getting 4 copies of the 1st feature story, but nothing from the second and third stories. 

You can see the page here:

http://www.polkcountynewspaper.com/new2/index_FEATURE.php

My code is attached.

I also want to make sure the feature stories are not JUST from our NEWS section. The feature stories might come from the sports section from time to time. Is it possible to just leave it open so that ANY story marked "feature_1", "feature_2" or "feature_3" gets placed on the homepage (no matter which section it comes from)?

Attachments:

FeatureStories.rtf 3K

We're almost there! Things are working great with a few minor adjustments in the code you sent. Now the only part I can't figure out is why I'm getting the same image for all 3 featured stories. It's the image from "feature 1" all 3 times.

By Damon - September 29, 2015

Hi,

I'm not sure why you are seeing the same image for all three stories.

Can you send in your CMS Builder and FTP details so I can take a closer look?
https://www.interactivetools.com/support/email_support_form.php?priority=regular

Don't post server details here in the forum.

Thanks!

Cheers,
Damon Edis - interactivetools.com

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