Version: 1.00, by jschefdog
Developer Last Online: May 2011
Version: 3.0.0
Rating:
Released: 04-20-2004
Last Update: Never
Installs: 7
Is in Beta Stage
No support by the author.
This is so simple I'm almost embarrased to post it here with all these great hacks, but I did some searching and only found posts from others who were looking for this feature. There is a hack for version 2 called Day Search which allows searching for all posts in the last xx days. I had added this hack for our v2 installation and wanted something similar for v3. After some searching here I didn't find anything, so I started tinkering with the search.php file and found a really simple way to make the standard Search page allow you to do something like this. All you have to do is defeat the test which checks if a keyword or user name was entered in the search form and then stops the search if they are both blank.
If anyone wants to try it, edit the search.php file and search for the following lines (at about line 250).
Code:
// error if no search terms
if (empty($query) AND empty($searchuser) AND empty($replyless))
Replace the "if" statement with the following line
Code:
if (empty($query) AND empty($searchuser) AND empty($replyless) AND ($searchdate == 0))
This will cause the 'searchspecifyterms' message to be bypassed provided the "Find Posts From" field is changed from the default of "Any Date". Actually, it will even work if you just comment out the whole if statement around this line, but then it will return lots of posts if the user leaves it at Any Date.
I can't believe it could be this simple, but I ran some tests and it seems to work. It even works with other search options such as selecting particular forums. I couldn't find any problems with it.
The next step is to figure out how to add some more "Find Posts From" options, such as "Last 2 Days", "Last 3 Days", etc. I haven't had a chance to look into this yet, but suspect it might be possible by changing the search_forum template. If I figure out how to do it I will post it here.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
OK, I figured out how to add more options to the "Find Posts From" drop down in the Search form. From the admin page, open the Style Manager and choose Edit Templates for the style you want to change. Expand "Search Templates" then select the search_forums template under it. Click Customize.
This will add options "2 Days Ago", "3 Days Ago", etc. You don't need to add all these options, or you can set other numbers of days if desired, but make sure to change the number in all 3 locations of the line. Each option line will add one drop down choice.
I was surprised to find out that there was already a "x_days_ago" phrase provided in vBulletin, even though they don't use it in the standard "Find Posts From" drop down. It seems that everything needed to search for all posts in the last X days is in standard vBulletin 3.0.0, but for some reason they did not allow it.
search.php?do=getdaily
or
search.php?do=getdaily&days=
wow they work - i never knew they where adding in vb to be honest.I posted a request for this a while back but it went unanswered as usual so i just naturally assumed they were`nt built in but obvious they are
cheers Zachery - so with this then theirs no need for the hack above.
so with this then theirs no need for the hack above.
I don't agree that the availability of "getdaily" makes this hack unecessary. This command was available in version 2 and the Day Search hack was built around it. But to use it you have to remember the syntax and type it into your browser. This is not something you should expect all the forum users to figure out and remember. The whole point of the Day Search hack was to add a way to access this function from the UI. The above hack is much simpler to implement and provides access to all the other search options (picking forums, sorting, etc).
My question is, since this hack works, why does the standard search.php code block it by cancelling any search that doesn't include a keyword or user name?
I've already posted something simular in another thread, no need to change any thing just put this code where you want the search box to show, like forum home
Code:
<form action="search.php" method="get" name="name">
<input type="hidden" name="do" value="getdaily">
Search for posts from the last <input type="text" value="1" name="days" size="3"> day(s) <input type="submit" value="Search">
</form>
I've already posted something simular in another thread, no need to change any thing just put this code where you want the search box to show, like forum home
Code:
<form action="search.php" method="get" name="name">
<input type="hidden" name="do" value="getdaily">
Search for posts from the last <input type="text" value="1" name="days" size="3"> day(s) <input type="submit" value="Search">
</form>
You can make a simple DHTML drop down to do this for you infact wayne luke has posted one at vB.com
Here are a couple of optional enhancements to the hack. If you want to block this type of search for a time period longer than a few days, you can modify the line listed in the first post to something like:
Code:
if (empty($query) AND empty($searchuser) AND empty($replyless) AND (($searchdate == 0) OR ($searchdate > 7)))
This example will not allow the search if Any Date is selected, or any option greater than "a week ago" is selected (7 days). You can change the 7 to any number of days you want.
Also, if you want to change the message that pops up if the user doesn't set "Find Posts From" to an acceptable value, you need to use the Phrase Manager.
In the admin page, open Phrase Manager under Languages and Phrases.
Click Search In Phrases
Enter searchspecifyterms in Search for Text and change Search In to Phrase Variable Name Only.
Click Find
Click Edit.
Enter the text that you want to appear in this message.
For example, if you uses the above 7 day limit, you might want to change the message text to something like.
Quote:
Please specify some keywords or valid user names to search on, or leave them blank and set Find Posts From to a value between Yesterday and A Week Ago to view all recent posts. There were no matches for your settings.
You can make a simple DHTML drop down to do this for you infact wayne luke has posted one at vB.com
That's a nice hack, and much more handy and obvious. This is the kind of feature I had hoped would be part of vB 3. To save people the trouble of hunting it down, here is the link.