Displaying new listings only

5 posts by 2 authors in: Forums > CMS Builder
Last Post: May 17, 2011   (RSS)

By andybarn - May 9, 2011

Hi

I am using CMSB ver 2.07 with the Basic Realty add-on.

From the home page I want a link that will display all listings added or updated in the last 30 days. Ideally I would like to use my current listings.php page to display these listings.

I have a search form on the home page and this works fine. I just need to know how to add a seperate link that will display properties added or updated in the last 30 days

Thanks for your help.

Andy

Re: [andybarn] Displaying new listings only

By Jason - May 9, 2011

Hi Andy,

You can link to a separate page and use a query that only returns records created/modified in the last thirty days. You can try something like this:


$thirtyDaysAgo = date("Y-m-d", strtotime("-30 days", strtotime(date("Y-m-d"))));

list($recentListingsRecords, $recentListingsMetaData) = getRecords(array(
'tableName' => 'listings',
'allowSearch' => false,
'where' => "createdDate >= '$thirtyDaysAgo' OR updatedDate >= '$thirtyDaysAgo'",
));


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: [andybarn] Displaying new listings only

By Jason - May 16, 2011

Hi Andy,

Yes, changing "-30 days" to "-1 days" changes the code so that it's only showing records created or updated within the last day.

In the code you posted, you're executing 2 queries: 1 that returns all records (10 per page) to a variables called $listingRecords, and 1 that returns all records created or updated within the last day to a variable called $recentListingsRecords.

If you want to only show the listings created or updated in the last day, make sure that you use $recentListingsRecords in your foreach loop.

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] Displaying new listings only

By andybarn - May 17, 2011

Hi Jason

Brilliant!

That was it, once I used $recentListingsRecords in my foreach loop , my page worked as I wanted - perfect!

Thanks for your great support

Andy