| v3.1 Modifications Questions on modifying 68 Classifieds. Please note these are not supported by 68 Classifieds, and may make future updates more difficult. |
|
|
|
Junior Member
|
|
Posts: 19
Join Date: May 2007
Location: Gilroy, CA
|
|
|
Adding date search to search.php -
06-04-2007, 06:08 PM
I need to add a drop-down menu to the search.php function that I have not been able to create using the "Add Extra Fields" option. This would be a dynamic search field which does a comparison between current date/time and the "dateadded" timestamp that is added to every new listing at the time of posting. The logic goes like this;
Search by;
Anytime = no restrictions (search all)
Last 24 hours = range = (currentdate/time) to (all dateadded equaling currentdate/time minus 24 hours)
Last 3 Days = range = (currentdate/time) to (all dateadded equaling currentdate/time-72 hours)
Last Week = range = (currentdate/time) to (all dateadded equaling currentdate/time-7days)
Last Month = range = (currentdate/time) to (all dateadded equaling currentdate/time-30 days)
The "Search Settings" option in the admin control panel only allows me to sort by dateadded, but I want users to search by dateadded using the above logic.
Can anyone help with this?
Thanks much!
|
|
|
|
Senior Member
|
|
Posts: 134
Join Date: Mar 2007
Location: Mammoth Lakes, Ca
|
|
|

06-05-2007, 12:33 AM
You might look into toplistings.php. The link for new listings in the default navigation section is toplistings.php?pg=new, which is basically a search by listing date/time. You could do something like "Recent ads: 24hr 3day Week Month". Each link would call toplistings.php?pg=xxx. Look at the switch code on line 61. You should be able to create some new cases with more specific parameters. (Theoretically anyway.)
Kirk V3.1.7 Developer May you & your loved ones be blessed with
Grace, Peace, Forgiveness, Love, Wisdom, & Joy
|
|
|
|
Junior Member
|
|
Posts: 19
Join Date: May 2007
Location: Gilroy, CA
|
|
|
Figured this one out, too.... -
06-29-2007, 02:40 AM
In order to incorporate the date search function on my search.php page I grabbed the code from the admin control panel where you can search your listings. One of the search features is by date, using either javascript pop-up calendars you can use to select a date range, or by clicking on the text links with preconfigured time frames; Lat month, last week, last 24 hours, and Today.
First, I grabbed the php code that runs the date search from the admin file called browselistings.php to make sure the search query could handle the data ranges;
//now get the search fields
if (isset($_REQUEST['fromdate']) && $_REQUEST['fromdate']<>"")
{
$enddate=date("Y-m-d");
if(isset($_REQUEST['enddate']) && $_REQUEST['enddate']<>"")
{
$enddate=$_REQUEST['enddate'];
}
$sSQL .= " AND p.dateadded BETWEEN '".trim($_REQUEST['fromdate'])."' AND '".trim($enddate)." 23:59:59'";
}
else
{
$today=date("Y-m-d");
$sSQL .= " AND p.dateadded BETWEEN '".$today." 00:00:00' AND '".$today." 23:59:59'";
}
if(isset($_REQUEST['active']) && $_REQUEST['active']=="N")
{
$sSQL .= " AND p.display<>'Y'";
}
elseif(isset($_REQUEST['active']) && $_REQUEST['active']=="Y")
{
$sSQL .= " AND p.display='Y'";
}
if(isset($_GET['orderby']) && isset($_GET['sortby']))
{
$orderby=$_GET['orderby'] .' '. $_GET['sortby'];
}
else
{
$orderby='dateadded DESC';
}
$sSQL .= " ORDER BY ". $orderby;
//now display the template
$today=date("Y-m-d");
$month = mktime(0,0,0,date("m")-1,date("d"),date("Y"));
$month = strftime("%Y-%m-%d",$month);
$week = mktime(0,0,0,date("m"),date("d")-7,date("Y"));
$week = strftime("%Y-%m-%d",$week);
$day = mktime(0,0,0,date("m"),date("d")-1,date("Y"));
$day = strftime("%Y-%m-%d",$day);
$class_tpl->assign('month', $month);
$class_tpl->assign('week', $week);
$class_tpl->assign('day', $day);
$class_tpl->assign('today', $today);
$class_tpl->assign('fromdate', @$_REQUEST['fromdate']);
$class_tpl->assign('enddate', @$enddate);
$class_tpl->assign('max', $max);
$class_tpl->assign('page', $currentPage);
$class_tpl->assign('first', $first);
$class_tpl->assign('prev', $prev);
$class_tpl->assign('next', $next);
$class_tpl->assign('last', $last);
$class_tpl->assign('pageNum', $pageNum);
$class_tpl->assign('pageNumber', $pageNumber);
$class_tpl->assign('maxPage', $maxPage);
if($numrows==0)
{
$class_tpl->assign('noresults', LANG_ADMIN_NO_RESULTS);
}
else
{
$class_tpl->assign('results', $results);
}
$class_tpl->assign('searchquery', $queryString_search);
$class_tpl->assign('totalPrice', $totPrice);
$class_tpl->display('layout.tpl.php');
Copied the above code into the search.php file.
Then I changed the text link options into a drop-down menu and added it to the search.tpl.php page like this;
<td valign="top" class="formleft"><div align="right">New Listings
added </div></td>
<td valign="top" class="formright"><select name="select">
<option selected>Antyime</option>
<option value="fromdate={$today}&enddate={$today}">Tod ay</option>
<option value="fromdate={$day}&enddate={$today}">Since Yesterday</option>
<option value="fromdate={$week}&enddate={$today}">In the Last
Week</option>
<option value="fromdate={$month}&enddate={$today}">In the
Last Month</option>
</select> </td>
Works great!
|
|
|
|
Senior Member
|
|
Posts: 134
Join Date: Mar 2007
Location: Mammoth Lakes, Ca
|
|
|

06-30-2007, 11:55 AM
I did some searches on your site and came up with results outside of the time frame I specified. For instance I selected "last 24 hours" and put in "44 Magnum" and got ads from over a week ago. Also, I just selected "today" with no keyword and got five pages worth of ads from before today. Sorry to rain on your parade, but are you sure it's working right.
Kirk V3.1.7 Developer May you & your loved ones be blessed with
Grace, Peace, Forgiveness, Love, Wisdom, & Joy
Last edited by midi510 : 06-30-2007 at 11:59 AM.
|
|
|
|
Junior Member
|
|
Posts: 19
Join Date: May 2007
Location: Gilroy, CA
|
|
|
Date search NOT working -
07-03-2007, 01:31 AM
You're right, Kirk. When I do the search my query string is all screwed up, with odd characters in it like this;
"...select=fromdate%3D2007-07-02%26enddate%3D2007-07-02..."
It looks like enclosing the date parameters in quotes inside of an option/select form tag converts the { and } to unreadable characters.
Any ideas on how to properly format the syntax for this date search in a drop-down menu so that this doesn't happen?
Last edited by abkeller : 07-03-2007 at 01:31 AM.
Reason: misspelling
|
|
|
|
Senior Member
|
|
Posts: 134
Join Date: Mar 2007
Location: Mammoth Lakes, Ca
|
|
|

07-03-2007, 10:28 AM
I'd like to spend some time on this, but I just have too many other things going on. I'll let you know if I do get any results.
Kirk V3.1.7 Developer May you & your loved ones be blessed with
Grace, Peace, Forgiveness, Love, Wisdom, & Joy
|
| Thread Tools |
|
|
| Display Modes |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Powered by vBulletin® Version 3.6.3 Copyright ©2000 - 2007, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com
|