Back to General Articles

last 48 hours search
by whodah 02 May 2005

what this hack does: shows the last 48 hours worth of posts
difficulty to install (scale of 1 to 10, 10 being the hardest): 3
files to mod: 1
templates to mod: 1

i take no responsibility if this breaks your forums. this probably violates the vB warranty due to a file modification. u break it, u buy it, yaddi yaddi. don't do this hack... having said that...

so the 'New Posts' link doesn't always work... u sign on, u leave w/out reading all the messages, come back, some are marked as read and don't show up on 'New Posts'... things of that nature.

so on our old forum, pnphpbb, i added a search function to show just the last 48 hours of posts.

once we migrated to vB, this had to be the feature i got the most PM's on that my peeps missed!!!

ok, so it's a very easy hack. probably violates a vB warranty, so u break it, u buy it. i take no responsibility, yaddi yaddi..

here we go!

file: forums/search.php
find:
Code:
	if ($_REQUEST['do'] == 'getnew' AND $bbuserinfo['lastvisit'] != 0)
	{
		// if action = getnew and last visit date is set
		$datecut = $bbuserinfo['lastvisit'];
	}
	else
	{
		$_REQUEST['do'] = 'getdaily';
		if ($days < 1)
		{
			$days = 1;
		}
		$datecut = TIMENOW - (24 * 60 * 60 * $days);
	}
insert the 'elseif' statement right between the if and else as such (or just replace it w/ this code):
Code:
	if ($_REQUEST['do'] == 'getnew' AND $bbuserinfo['lastvisit'] != 0)
	{
		// if action = getnew and last visit date is set
		$datecut = $bbuserinfo['lastvisit'];
	}
	// 2005.04.30 whodah - last 48 hours mod
	elseif ($_REQUEST['do'] == 'last48hours')
  {
		$days = 2;
		$datecut = TIMENOW - (24 * 60 * 60 * $days);
	}
	// end 2005.04.30 whodah - last 48 hours mod
	else
	{
		$_REQUEST['do'] = 'getdaily';
		if ($days < 1)
		{
			$days = 1;
		}
		$datecut = TIMENOW - (24 * 60 * 60 * $days);
	}
you are done. if you now visit:
Code:
www.yourdomain.com/forums/search.php?do=last48hours
it will show u the last 48 hours worth of posts.

(it should be pretty obvious how to modify it to show the last 7 days or whatever u want. we like 48 hours...)

so now, we added a link to that next to 'New Posts' on our NavBar...

to do this, edit your 'navbar' template. for those that dont' know how:
  • log on to your appliance admin: http://www.yourdomain.com/forums/admincp
  • click 'Styles & Templates' on the left, then 'Style Manager'.
  • on the right hand menu, drop down to 'Edit Templates' and choose 'Go'.
  • double click 'Navigation / Breadcrumb Templates'
  • double click 'navbar'

somewhere in here, add a link to your new search function. in our case, we put it next to 'New Posts'. to do this, find:
Code:
<td class="vbmenu_control"><a href="calendar.php?$session[sessionurl]">$vbphrase[calendar]</a></td>
afterwards add:
Code:
<td class="vbmenu_control"><a href="search.php?do=last48hours" accesskey="5">Last 48 Hours</a></td>
enjoy!

Who Dah?

vblts.ru supports vBulletin®, 2022-2024