Featured Article
5 posts by 2 authors in: Forums > CMS Builder
Last Post: December 1, 2009 (RSS)
By design9 - December 1, 2009
I wanted to see if you could guide me in the right direction.
I have an article section with articles that are feeding into various categories (Pregnancy, Elementary Years, Preschoolers, etc.) On each main category page, I feed the articles for that topic on a page by using a where statement. I need to have a featured article section on the page that will be a section that shows 3 featured articles that shows the thumbnail photo, title and summary. This information pulls from the articles section in my backend that I have already built. I am trying to figure out a way to get the featured articles to pull in on the page. I didn't think I could use another where statement since I am already using one on the page to pull in all articles that relate the main topic for that page. Need to figure out a good way to get these features to pull into the page.
I also need to set up these features so they can expire on a certain date so the user doesn't have to manually delete them each month. Need to figure out a way to set that as well. Also, I need these features to pull in from the articles section that is already built and need to figure out a way to pull in a specific article (id# ?) into the features area. This way the user would not have to re-type the article on the main page.
Here is an example of the main page design: the featured area in the middle with the 3 photos, title and summary text and the articles that pull in are at the bottom (this area is working/has php coding).
http://www.carolinaparent.com/test/elementary.php
Thank you,
April
Re: [apdance9] Featured Article
By gkornbluth - December 1, 2009 - edited: December 1, 2009
I think that the this post http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/Featured_Article_P75312 might give you a head start.
Do you want the article to disappear from the site or just the featured status to disappear ?
Best,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Featured Article
By design9 - December 1, 2009
I only want the featured article section to expire on a specific date entered. I don't want the entire article to disappear. I had originally had a checkbox set up within the articles section but quickly realized that would not work because the entire article would expire. Also, that didn't work because I have it set up so a single article could be assigned to appear on multiple category pages and the featured box didn't work here because it would show up on all those categories page instead of the one I wanted.
I just need to figure out a better way to handle this directly on the page so the features area can expire when entered and how to pull an article from the section I already have set-up. Don't know the best way to make this happen.
Thanks!
April
Re: [apdance9] Featured Article
You could compare the date published with the current date and use an if statement to show the featured article
There are some posts on comparing dates that might point you in the right direction.
Here's an excerpt from The CMSB Cookbook that discusses an approach to comparing dates. You should be able to easily modify the code to fit your needs.
Hope it helps.
Jerry Kornbluth
__________________________
COMPARING DATES
When combined with the “if” statement, this extremely useful concept can be used to show or hide fields based on a particular date, automatically archive records after a specified time period and perform many other functions.
Here’s the basic idea of how to compare a date field to today’s date on a list page. This example uses a date field called “opening_reception” in a multi record editor called “exhibitions”. The goal was to automatically hide the opening reception date after the date had passed.
<!– First you’ll need a “foreach” statement to display each record. -->
<?php foreach ($exhibitionsRecords as $record): ?>
Since dates are normally expressed as months, days and years are hard to compare mathematically, the dates are converted to the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT
Dave suggested to first define a few variables and to use simple, descriptive names so that the process is easier to follow. Then set some rules for the comparisons. You can use mathematical operators like <, >, <= or >= between values to compare them in different ways.
<?php
$eventUnixTime = strtotime( $record['reception_date'] ); // seconds since 1970
$eventDateString = date("l, F jS", $eventUnixTime); // example format: Monday, June 1st
$currentUnixTime = time();
$currentDateString = date("l, F jS", $currentUnixTime);
$isEventToday = ($eventDateString == $currentDateString); // first comparison
$isEventOver = !$isEventToday && ($eventUnixTime < $currentUnixTime); // second comparison
$isFutureEvent = !$isEventOver && !$isEventToday; // third comparison
?>
Then it becomes a simple matter of comparing the variables
<?php if ($isFutureEvent): ?>
Opening Reception: <?php echo $eventDateString ?>
<?php elseif ($isEventToday): ?>
The Opening reception is today. Don't miss it!!
<?php else: ?>
Sorry, you missed the Opening Reception.
<?php endif; ?>
and don’t forget the endforeach statement to close your loop.
<?php endforeach ?>
Or, Let’s say you want to group a set of meetings by future and past dates
You could use:
<div >UPCOMING MEETINGS:</div>
<?php foreach ($general_meetingsRecords as $record): ?>
<?php
$eventUnixTime = strtotime( $record['date'] ); // seconds since 1970
$eventDateString = date("l, F jS", $eventUnixTime); // example format: Monday, June 1st
$currentUnixTime = time();
$currentDateString = date("l, F jS", $currentUnixTime);
$isEventOver = !$isEventToday && ($eventUnixTime < $currentUnixTime);
$isFutureEvent = !$isEventOver && !$isEventToday;
?>
<?php if ($isFutureEvent): ?>
<br /><?php echo date("D, M jS, Y g:i a", strtotime($record['date'])) ?>
<br />
<?php echo $record['content'] ?>
<hr align="left" width="100" />
<?php endif; ?>
<?php endforeach ?>
<br />
<div >UPCOMING MEETINGS:</div>
<?php foreach ($general_meetingsRecords as $record): ?>
<?php
$eventUnixTime = strtotime( $record['date'] ); // seconds since 1970
$eventDateString = date("l, F jS", $eventUnixTime); // example format: Monday, June 1st
$currentUnixTime = time();
$currentDateString = date("l, F jS", $currentUnixTime);
$isEventOver = !$isEventToday && ($eventUnixTime < $currentUnixTime);
$isFutureEvent = !$isEventOver && !$isEventToday;
?>
<?php if ($isEventOver): ?>
<br /><?php echo date("D, M jS, Y g:i a", strtotime($record['date'])) ?>
<br />
<?php echo $record['content'] ?>
<hr align="left" width="100" />
<?php endif; ?>
<?php endforeach ?>
Note that you have to redefine the variables for each “foreach” loop
If you want to compare other field values, just define more variables and compare those as well.
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Featured Article
By design9 - December 1, 2009
The issue now is how to feed in a selected article from my articles section into the featured section. I need to feed in the photo, title and summary from a specific article. I don't know the best way to get in a specific article or article id number. That is where I am now stumped.
Thanks!
April