|
|
#1 |
|
Member
Join Date: May 2007
Posts: 37
Rep Power: 8 ![]() |
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!
__________________
private signature 68Classifieds - Developer Edition, v.3.1.7 |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Mar 2007
Location: Mammoth Lakes, Ca
Posts: 135
Rep Power: 12 ![]() |
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 withGrace, Peace, Forgiveness, Love, Wisdom, & Joy |
|
|
|
|
|
#3 |
|
Member
Join Date: May 2007
Posts: 37
Rep Power: 8 ![]() |
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!
__________________
private signature 68Classifieds - Developer Edition, v.3.1.7 |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Mar 2007
Location: Mammoth Lakes, Ca
Posts: 135
Rep Power: 12 ![]() |
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 withGrace, Peace, Forgiveness, Love, Wisdom, & Joy Last edited by midi510; 06-30-2007 at 11:59 AM. |
|
|
|
|
|
#5 |
|
Member
Join Date: May 2007
Posts: 37
Rep Power: 8 ![]() |
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?
__________________
private signature 68Classifieds - Developer Edition, v.3.1.7 Last edited by abkeller; 07-03-2007 at 01:31 AM. Reason: misspelling |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Mar 2007
Location: Mammoth Lakes, Ca
Posts: 135
Rep Power: 12 ![]() |
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 withGrace, Peace, Forgiveness, Love, Wisdom, & Joy |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Search members by join date not working | zman78 | v3.1 Questions & Support | 9 | 10-01-2007 07:07 AM |
| Adding extra field to search.php... | abkeller | v3.1 Modules & Modifications | 4 | 06-05-2007 12:15 AM |
| Adding Short Description To Search Results | CB | v3.1 Questions & Support | 5 | 06-22-2006 04:52 PM |
| Adding the Owner Name to the search results | robgo777 | v3.1 Questions & Support | 6 | 06-13-2006 10:21 AM |
| Adding Search to | sleepy | HTML, CSS, and Design Help | 8 | 04-09-2006 12:12 PM |