Featured Story?

8 posts by 2 authors in: Forums > CMS Builder
Last Post: February 9, 2010   (RSS)

By InfamousNugz - October 20, 2009

Dear Interactive Tools,
I have a client who posts news stories. They would like to have a checkbox within the CMS that makes the story there featured story which will then put it in its own Featured Story area above the other news stories. It cant be its own section because they want it to archive with all the old news stories so I did not know if there was something I could add to the code that would make a single story appear if it were checked.

Thank you for your help!

Re: [sagentic] Featured Story?

By InfamousNugz - October 21, 2009 - edited: October 21, 2009

This is not exactly what I needed done. I need when featured is checked for this story to appear in a completely different position on the page away from the other news stories all by itself.

I would like a local news story once checked off in the CMS to go to the featured news section. I assume I would need to duplicate the information with some kind of addition to the checkbox field. I also use an older version that has a bug with checkboxes that only allows me to use 1 and 2 to validate my fields.

Re: [InfamousNugz] Featured Story?

By Kenny - October 21, 2009 - edited: October 21, 2009

No problem - just add a few more steps to what I said earlier.

On your (news) list page you need to insert the foreach statements twice - one for each section of news articles.

The first one (featured articles) needs to have an if statement added to it like this:

<?php foreach ($newsRecords as $record): ?>
<?php if ($record['featured']): ?>

//Insert other code here

<?php endif ?>
<?php endforeach; ?>


Does that help?


Kenny

Re: [sagentic] Featured Story?

By InfamousNugz - October 21, 2009

Yes that worked thank you!

Re: [sagentic] Featured Story?

By InfamousNugz - February 9, 2010

I actually have an update to this. The person would like to hide this from the news stories if it is marked as featured. So in its current form it will display in 2 spots if it is marked as the featured story. Anyway to go about this?

Re: [InfamousNugz] Featured Story?

By Kenny - February 9, 2010

Sure - you just have to add one little exclamation mark to the code

<?php foreach ($newsRecords as $record): ?>
<?php if (!$record['featured']): ?>

//Insert other code here

<?php endif ?>
<?php endforeach; ?>


The exclamation mark = not

So what the statement is saying is if it is "not" featured, then display the record.

Let me know if that doesn't work.

Kenny

Re: [sagentic] Featured Story?

By InfamousNugz - February 9, 2010

Perfect thanks!