Custom Start Date / End Date

6 posts by 3 authors in: Forums > CMS Builder
Last Post: July 11, 2012   (RSS)

By wevolutions - July 7, 2012

I have regular listings that I show on my website but I wish to have certain listings being "featured" in another page for a specified time period.

I know about the publishDate features but I want to be able to use a custom field (eg. start_date) in order to manually input the desired time period. I noticed that when I used the publishDate option, all my regular listings just disappear.

What is the best way to set this up? I created a checkbox named "featured_ad" so that once I check this option, it will be displayed based on the manual date that I enter.

Re: [WEVOLUTIONS] Custom Start Date / End Date

By Jason - July 9, 2012

Hi,

Is your goal to always show the same batch of listings, but at certain times, highlight some listings as featured?

If so, the quickest solution is to use the checkbox method you mentioned. You can then detect if a listing is featured as you are outputting listings.

Hope this helps,
---------------------------------------------------
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] Custom Start Date / End Date

Hi Jason, you are correct. I want the regular listings to always remain but I also want some featured listings to be shown from time to time.

I need assistance in getting the coding to do this.

I want to have a "Start Date" and an "End Date" for the featured listings which I will input manually.

How do I input the code to use the dates as I mentioned above and also to implement the checkbox for the featured listings?

Re: [WEVOLUTIONS] Custom Start Date / End Date

By Jason - July 11, 2012

Hi,

If you want to use start and end dates to define if a record is featured or not, you won't need the check box.

Here is an untested example of some code to detect if a given record is featured or not while outputting your event records:

EXAMPLE:
<?php $currentDateTime = time(); ?>
<?php foreach ($myEvents as $event): ?>

<?php if (strtotime($event['start_date']) <= $currentDateTime && strtotime($event['end_date']) >= $currentDateTime): ?>
//event is featured
<?php else: ?>
//event is not featured
<?php endif ?>

<?php endforeach ?>


Hope this helps get you started
---------------------------------------------------
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] Custom Start Date / End Date

Hi Jason, thank you for your response. I don't think this is what I have in mind.

Here is what I need basically:

1. I have a checkbox named "featured_ad".
2. I have a Start Date named "featuredStartDate".
3. I have an End Date named "featuredEndDate".

I want to display all listings that are checked and which have the Start Date and End Date manually inputted. The listings will show only for this specified time period and then not display anymore.

I can't make this any simpler. I hope this helps. Thank you.