![]() |
Search All Posts From Date (Day Search)
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 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 Code:
if (empty($query) AND empty($searchuser) AND empty($replyless) AND ($searchdate == 0)) 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. |
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. Code:
<option value="1" $searchdateselected[1]>$vbphrase[yesterday]</option> Code:
<option value="2" $searchdateselected[2]><phrase 1="2">$vbphrase[x_days_ago]</phrase></option> 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. |
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 |
What lasto said,
search.php?do=getdaily or search.php?do=getdaily&days= |
Quote:
cheers Zachery - so with this then theirs no need for the hack above. |
Quote:
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"> |
Quote:
|
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))) 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.
Quote:
|
Quote:
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. |
Quote:
forumid=X exclode=X,Y,Z |
Quote:
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. |
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. |
Quote:
Bravo, and thank you! |
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.
|
Like some posters said, this feature is built into vB - you just need to add the template mod described above - no hack needed. :)
|
Quote:
This is the code I found in my search.php file: Code:
// error if no search terms Code:
// error if no search terms Is there some other setting I need to change? Thanks. |
I see my mistake. I need to remove the "empty" command in front of the 'searchdate' pointer. All is OK now.
|
All times are GMT. The time now is 04:44 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|