Topic: forum based php question (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=28611" title="Pages that link to Topic: forum based php question (Page 1 of 1)" rel="nofollow" >Topic: forum based php question <span class="small">(Page 1 of 1)</span>\

 
Ensellitis
Paranoid (IV) Inmate

From: Kansas City, MO , USA
Insane since: Feb 2002

posted posted 11-05-2006 08:13

i am in the middle of making an online community setup... i recently started taking on the forum part of it...

now, my question is... how would one go about making those "folder" icons highlight when there are new posts there?

if you need to take a look, here is the site...

i want to make all those green icons dark green when there are posts in there the user has read, and the color they are now when there are new posts... any idea?

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 11-05-2006 14:38

Well, here at the Asylum, westore the last visit time, as well as the time we last saw you.
Then we color anything newer than last visit time, updating the last visit time
if it's smaller than last seen time -15 minutes or some such.

I can get you the code, but not right now...

Ensellitis
Paranoid (IV) Inmate

From: Kansas City, MO , USA
Insane since: Feb 2002

posted posted 11-05-2006 22:36

that would be great, thanks!

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 11-06-2006 10:24

ok, here you go:

This is being done on every request to the Asylum

code:
// set cookies for the highlighting of unread forums & threads
$iMinimumTimeBetweenVisits = 900;
if (g_retrieveUserSetting('lastVisit') !== NULL && (time() - $iMinimumTimeBetweenVisits > g_retrieveUserSetting('lastVisit')))
{
	g_storeUserSetting('lastVisit',g_retrieveUserSetting('thisVisit'));
}
elseif  (g_retrieveUserSetting('lastVisit') === NULL)
{
	g_storeUserSetting('lastVisit',time());
}
g_storeUserSetting('thisVisit',time());




g_***UserSettings are basically wrappers around a cookie

code:
function g_storeUserSetting($strKey,$value)
{
	$arrData = false;
	if (isset($_COOKIE[$GLOBALS['g_str']['%%cookiename']. 'settings']))
	{
		$arrData = @unserialize(urldecode($_COOKIE[$GLOBALS['g_str']['%%cookiename']. 'settings']));
	}
	if (!is_array($arrData))
		$arrData = array();
	$arrData[$strKey] = $value;
	$strData = urlencode(serialize($arrData));
	setcookie($GLOBALS['g_str']['%%cookiename']. 'settings',$strData,time() + 3600 * 24 * 30,'/',CONFIG_DOMAIN,0);
	$_COOKIE[$GLOBALS['g_str']['%%cookiename']. 'settings'] = $strData;
}

function g_retrieveUserSetting($strKey)
{	
	if (isset($_COOKIE[$GLOBALS['g_str']['%%cookiename']. 'settings']))
	{				
		$arrData = @unserialize(urldecode($_COOKIE[$GLOBALS['g_str']['%%cookiename']. 'settings']));
		if (isset($arrData[$strKey]))
			return $arrData[$strKey];
		else
			return NULL;
	}
	return NULL;	
}



and of course, the actual function to check if something is newer...

code:
function g_isNewSinceLastVisit($pageDate)
{
	$strFormat = "Y-m-d H:i:s";
	if (is_numeric($pageDate))
		$pageDate = date($strFormat,$pageDate);
	return ((g_retrieveUserSetting('lastVisit') != '') && $pageDate > date($strFormat, g_retrieveUserSetting('lastVisit')));
}



Hope this helps you,
so long,

->Tyberius Prime



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu