Featured Story?

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

Re: [InfamousNugz] Featured Story?

By Kenny - October 20, 2009


Create a checkbox field called "Featured" then change the orderBy to featured.

This means all of the "featured" articles will be first. If you have a date field you sort by featured, date DESC - this will make the featured stories come up first then the latest story by the latest date.

Make sense? Let us know if you need more help with this.


Kenny

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?

Yes that worked thank you!

Re: [sagentic] Featured Story?

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?

Perfect thanks!