View Full Version : Search All Posts From Date (Day Search)
jschefdog
04-20-2004, 10:00 PM
This is so simple I'm almost embarrased :o 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 (https://vborg.vbsupport.ru/showthread.php?t=37946) 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).
// error if no search terms
if (empty($query) AND empty($searchuser) AND empty($replyless))
Replace the "if" statement with the following line
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.
jschefdog
04-21-2004, 03:56 PM
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.
Search for the following line in this template.
<option value="1" $searchdateselected[1]>$vbphrase[yesterday]</option>
Then add lines similar to the following after this line:
<option value="2" $searchdateselected[2]><phrase 1="2">$vbphrase[x_days_ago]</phrase></option>
<option value="3" $searchdateselected[3]><phrase 1="3">$vbphrase[x_days_ago]</phrase></option>
<option value="4" $searchdateselected[4]><phrase 1="4">$vbphrase[x_days_ago]</phrase></option>
<option value="5" $searchdateselected[5]><phrase 1="5">$vbphrase[x_days_ago]</phrase></option>
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.
lasto
04-21-2004, 04:05 PM
looking good m8 and u r right in what u say but this sort of stuff should already of been built into vb in first place.
Job well done m8
Zachery
04-21-2004, 04:09 PM
What lasto said,
search.php?do=getdaily
or
search.php?do=getdaily&days=
lasto
04-21-2004, 04:28 PM
What lasto said,
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.
jschefdog
04-21-2004, 04:54 PM
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?
Beermonster
04-21-2004, 05:08 PM
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
<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>
Zachery
04-21-2004, 05:12 PM
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
<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 :)
jschefdog
04-21-2004, 05:25 PM
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:
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.
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.
jschefdog
04-21-2004, 05:54 PM
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.
http://www.vbulletin.com/forum/showthread.php?p=657712
The only real advantage my hack has is that it provides more search control, such as only showing recent posts in selected forums.
Zachery
04-21-2004, 05:56 PM
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.
http://www.vbulletin.com/forum/showthread.php?p=657712
The only real advantage my hack has is that it provides more search control, such as only showing recent posts in selected forums.
You should be able to exclude, or only look at one specific forum as well
forumid=X
exclode=X,Y,Z
jschefdog
04-21-2004, 07:48 PM
You should be able to exclude, or only look at one specific forum as well
forumid=X
exclode=X,Y,ZThanks for the tip Zachery. I tried these and they work fine. For example:
search.php?do=getdaily&days=30&forumid=26
search.php?do=getdaily&days=30&exclude=28,29
Specifying the forumid will also include children, which is nice. This would allow adding buttons to do specific searches such as "Last Month for Forum X" or "Last Week for Category Y", but does not provide the flexibility of being able to do "Last X Days" searches from the Advanced Search form. With the hack described in this thread, you can select any combination of forums (thanks to the great new search features in vb 3) and then view all the posts from the last x days in those forums. You can also list the results by posts, which I don't think is possible with getdaily.
jschefdog
04-21-2004, 08:06 PM
Related to this topic, it seems that whenever you run a search using "getdaily", the Search Results web page always says:
Search: Posts From Last Day
Regardless of the number of days you specify. Not a big deal, but it would be nice if it listed the number of days used in the search.
Jon Matcho
05-25-2004, 09:15 PM
...I'm almost embarrased to post it here with all these great hacks...The simplicity of this hack is near algorithmic poetry. I salute you for finding this gem!!!
Bravo, and thank you!
MickDoneDee
06-01-2004, 07:14 PM
So simple, but so useful - qualities of a great hack. Should be included in future versions. I've also added the optional enhancements. It works like a charm.
Erwin
06-02-2004, 01:22 AM
Like some posters said, this feature is built into vB - you just need to add the template mod described above - no hack needed. :)
jksgvb
01-14-2007, 11:35 PM
...With the hack described in this thread, you can select any combination of forums (thanks to the great new search features in vb 3) and then view all the posts from the last x days in those forums. You can also list the results by posts, which I don't think is possible with getdaily.
Thanks so much for posting this. This is exactly the way I need the advanced search in my forum to work. Unfortunately, when I modify the search.php file as described, searching operates just as before--still returning the error if 'key word' and 'user name' fields are left blank.:confused:
This is the code I found in my search.php file:
// error if no search terms
if (empty($vbulletin->GPC['query']) AND empty($vbulletin->GPC['searchuser']) AND empty($vbulletin->GPC['replyless']))
and this is what I changed it to:
// error if no search terms
if (empty($vbulletin->GPC['query']) AND empty($vbulletin->GPC['searchuser']) AND
empty($vbulletin->GPC['searchdate == 0']) AND empty($vbulletin->GPC['replyless']))
I'm running vBulletin 3.6.4 btw.
Is there some other setting I need to change? Thanks.
jksgvb
01-15-2007, 08:22 PM
I see my mistake. I need to remove the "empty" command in front of the 'searchdate' pointer. All is OK now.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.