Author |
Topic |
|
WrightA
Starting Member
4 Posts |
Posted - 06 September 2003 : 04:54:52
|
Hi,
My site has a forum, which visitors can access by using the 'forum' link from the menu. A nice change I'd like to do is to display the number of active topics on the homepage of the site, so that the visitor knows straight away if there are new posts to read.
Would this simply be a copy and paste of code into my homepage, or is it more complex than that.
Any help, pointers greatly appreciated,
Thanks,
WrightA |
Edited by - ruirib on 06 September 2003 06:24:32 |
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 06 September 2003 : 05:00:07
|
I have a small count on my forums (www.ckyalliance.co.uk/forum) next to the Active Topic link.
If I remember, this is what I did:
Find:
%>
<!--#INCLUDE FILE="inc_func_common.asp" -->
<%
and add this below:
dim ActiveTopicCount
Then find:
select case Request.Form("Method_Type")
case "login"
strEncodedPassword = sha256("" & Request.Form("Password"))
select case chkUser(strDBNTFUserName, strEncodedPassword,-1)
case 1, 2, 3, 4
Call DoCookies(Request.Form("SavePassword"))
strLoginStatus = 1
case else
strLoginStatus = 0
end select
case "logout"
Call ClearCookies()
end select
And add this above:
ActiveTopicCount = -1
if IsEmpty(Session(strCookieURL & "last_here_date")) then
Session(strCookieURL & "last_here_date") = ReadLastHereDate(strDBNTUserName)
end if
if not IsNull(Session(strCookieURL & "last_here_date")) then
if not blnHiddenForums then
'## Forum_SQL - Get ActiveTopicCount from DB
strSql = "SELECT COUNT(" & strTablePrefix & "TOPICS.T_LAST_POST) AS NUM_ACTIVE "
strSql = strSql & "FROM " & strTablePrefix & "TOPICS "
strSql = strSql & "WHERE (((" & strTablePrefix & "TOPICS.T_LAST_POST)>'"& Session(strCookieURL & "last_here_date") & "'))"
strSql = strSql & " AND " & strTablePrefix & "TOPICS.T_STATUS <= 1"
set rs = my_Conn.Execute(strSql)
if not rs.EOF then
ActiveTopicCount = rs("NUM_ACTIVE")
else
ActiveTopicCount = 0
end if
end if
end if
Then replace the Active Topic link with this:
" <a href=""active.asp""" & dWStatus("See what topics have been active since your last visit...") & " tabindex=""-1""><acronym title=""See what topics have been active since your last visit..."">Active Topics"
if ActiveTopicCount > 0 then Response.Write " (<font color=""" & strHoverFontColor & """><b>" & ActiveTopicCount & "</b></font>)"
I think that's right, but I may be wrong. Sorry
Anyway, just use the same idea on your homepage |
|
|
WrightA
Starting Member
4 Posts |
Posted - 06 September 2003 : 11:03:20
|
Cheers,
I notice you also have an Active Users page, could you post the code for that please?
Cheers
WrightA |
|
|
Links Shadow
Starting Member
3 Posts |
Posted - 06 September 2003 : 11:41:54
|
Are those changes done to the inc_header.asp file, if not which ones need to be changed to have that appear on all pages like you have mortioli? |
Edited by - Links Shadow on 06 September 2003 11:48:21 |
|
|
dayve
Forum Moderator
USA
5820 Posts |
Posted - 06 September 2003 : 13:04:27
|
this mod does not work if you change the drop list value for Active Topics Since. |
|
|
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 06 September 2003 : 16:01:38
|
Yeah the changes are done in inc_header.asp
dayve, the Active Topics since doesn't save your chosen amount of time does it?
The Active Users would be...
Above where you add the large part of the Active Topic code, add:
'### ACTIVE USER COUNT - OJM ADDED ###
intTotalActiveMembers = 0
intTotalActiveGuests = 0
intTotalActiveUsers = 0
'## Ls3k - Before we can do anything we need to get rid of those slackers who have left ;)
deleteInactiveUsers()
'## Ls3k - Get counts
strSql = "SELECT COUNT(AU_IP) AS CNT FROM " & strTablePrefix & "ACTIVE_USERS WHERE MEMBER_ID = -1"
set rs = my_conn.execute (strSql)
intTotalActiveGuests = rs("CNT")
rs.close
set rs = nothing
strSql = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "ACTIVE_USERS WHERE MEMBER_ID <> -1"
set rs = my_conn.execute (strSql)
intTotalActiveMembers = rs("CNT")
rs.close
set rs = nothing
intTotalActiveUsers = intTotalActiveMembers + intTotalActiveGuests
'### ACTIVE USER COUNT - OJM ADDED ###
Then the Active Users link would be:
" <a href=""active_users.asp""" & dWStatus("See who is online...") & " tabindex=""-1""><acronym title=""See who is online..."">Active Users (<font color=""" & strHoverFontColor & """><b>" & intTotalActiveUsers & "</b></font>)</acronym></a>" & vbNewline & _ |
|
|
dayve
Forum Moderator
USA
5820 Posts |
Posted - 07 September 2003 : 00:07:19
|
quote: Originally posted by mortioli
dayve, the Active Topics since doesn't save your chosen amount of time does it?
it could if you wrote it to a session or cookie like so...
Response.Cookies("lastDate") = lastDate
in the Active Topics page. I have not tried this but I'm sure something like this would work. You could then replace your SQL statement to compare to this cookie instead of the default last visit session object. |
|
|
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 07 September 2003 : 03:53:23
|
I don't think anyone uses the last seen part (on my forums), so I'll leave it. Cheers anyway! |
|
|
ssnapier
Junior Member
USA
126 Posts |
Posted - 08 September 2003 : 10:57:06
|
off topic, but CKY is pretty funny!!!!!!! I crack up every time I listen to the Chinese freestyle clip... LOL |
If freedom were shareware, soldiers are the ones who pay for it. |
|
|
wii
Free ASP Hosts Moderator
Denmark
2632 Posts |
Posted - 08 January 2004 : 13:21:00
|
I also use this code, but could we fix it, so users don´t have to refresh before actually seeing the correct number?
I mean, if you visit the forum and there are 6 users online (according to the active user count in the default.asp page), it will show only 5 at the top using the below code, after refreshing the page, it will show the correct number 6.
quote: Originally posted by mortioli
Yeah the changes are done in inc_header.asp
dayve, the Active Topics since doesn't save your chosen amount of time does it?
The Active Users would be...
Above where you add the large part of the Active Topic code, add:
'### ACTIVE USER COUNT - OJM ADDED ###
intTotalActiveMembers = 0
intTotalActiveGuests = 0
intTotalActiveUsers = 0
'## Ls3k - Before we can do anything we need to get rid of those slackers who have left ;)
deleteInactiveUsers()
'## Ls3k - Get counts
strSql = "SELECT COUNT(AU_IP) AS CNT FROM " & strTablePrefix & "ACTIVE_USERS WHERE MEMBER_ID = -1"
set rs = my_conn.execute (strSql)
intTotalActiveGuests = rs("CNT")
rs.close
set rs = nothing
strSql = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "ACTIVE_USERS WHERE MEMBER_ID <> -1"
set rs = my_conn.execute (strSql)
intTotalActiveMembers = rs("CNT")
rs.close
set rs = nothing
intTotalActiveUsers = intTotalActiveMembers + intTotalActiveGuests
'### ACTIVE USER COUNT - OJM ADDED ###
Then the Active Users link would be:
" <a href=""active_users.asp""" & dWStatus("See who is online...") & " tabindex=""-1""><acronym title=""See who is online..."">Active Users (<font color=""" & strHoverFontColor & """><b>" & intTotalActiveUsers & "</b></font>)</acronym></a>" & vbNewline & _
|
|
|
|
Topic |
|