Show how many messages since yours IN PAGE TITLE - Posted (5750 Views)
Junior Member
balexandre
Posts: 418
418
I just made this for my self as an add-on of what I did in the Forum main page (show the last 10 messages posted).
the objective was something like "GMAIL - Inbox (3)" and this is the code I uses in my page.
you can have the same in 2 steps please note that this is only to change the title of the page, the Top 10 messages that you can see in the images below ARE NOT included in this tutorial, another thing is, this only works with Access DB and MySQL above version 4.x.
  • ADD THIS IN inc_header.asp BEFORE the 2nd response.write function that had the tag:
    Code:
    <title>
    (so, search for
    Code:
    <title>
    , the 2nd one STOP and scroll up until you get the response.write, above that line, paste the include)

    paste this:

    Code:
    %><!--#INCLUDE FILE="inc_showMsgNrOnTitle.asp"><%
  • in a new file called
    Code:
    inc_showMsgNrOnTitle.asp
    paste this:

    Code:
    <%
    ' ********************************************************************************************
    ' SHOW NUMBER OF NEW MESSAGES IN TITLE IF LOGGED IN (MORE THAN 20, WILL OUTPUT +20)
    ' Built in: 26th May 2007 by Bruno Alexandre <bruno.in.dk@gmail.com>
    ' version: 0.0.2 | (29th May 2007) | updated with TopSQL() so it runs in mySQL as well (>4.x)
    ' version: 0.0.1 | (26th May 2007) | Mod Start
    ' ********************************************************************************************
    strNewMessages = ""
    intNewMessages = 0
    ' We only see the messages if the user is Logged In
    if strDBNTUserName <> "" then
    ' Get the last 20 messages order by Date
    sqlstr = "SELECT M_NAME FROM ( " & _
    "SELECT " & strTablePrefix & "TOPICS.CAT_ID, " & strTablePrefix & "TOPICS.FORUM_ID, " & strTablePrefix & "TOPICS.TOPIC_ID, " & strTablePrefix & "TOPICS.T_SUBJECT, '' AS MSG_ID, " & strTablePrefix & "TOPICS.T_MESSAGE AS MSG, " & strTablePrefix & "TOPICS.T_DATE AS MSG_DATE, " & strTablePrefix & "MEMBERS.MEMBER_ID, " & strTablePrefix & "MEMBERS.M_NAME " & _
    "FROM " & strTablePrefix & "MEMBERS INNER JOIN " & strTablePrefix & "TOPICS ON " & strTablePrefix & "MEMBERS.MEMBER_ID = " & strTablePrefix & "TOPICS.T_AUTHOR " & _
    "UNION ALL " & _
    "SELECT " & strTablePrefix & "TOPICS.CAT_ID, " & strTablePrefix & "TOPICS.FORUM_ID, " & strTablePrefix & "TOPICS.TOPIC_ID, " & strTablePrefix & "TOPICS.T_SUBJECT, " & strTablePrefix & "REPLY.REPLY_ID AS MSG_ID, " & strTablePrefix & "REPLY.R_MESSAGE as MSG, " & strTablePrefix & "REPLY.R_DATE as MSG_DATE, " & strTablePrefix & "MEMBERS.MEMBER_ID, " & strTablePrefix & "MEMBERS.M_NAME " & _
    "FROM (" & strTablePrefix & "TOPICS INNER JOIN " & strTablePrefix & "REPLY ON " & strTablePrefix & "TOPICS.TOPIC_ID = " & strTablePrefix & "REPLY.TOPIC_ID) INNER JOIN " & strTablePrefix & "MEMBERS ON " & strTablePrefix & "REPLY.R_AUTHOR = " & strTablePrefix & "MEMBERS.MEMBER_ID " & _
    ") a " & _
    "ORDER BY MSG_DATE DESC;"

    Set objRec = Server.CreateObject ("ADODB.Recordset")
    objRec.Open TopSQL(sqlstr, 20), My_Conn
    objRec.moveFirst()
    do until objRec.EOF
    if objRec.fields("M_NAME") = strDBNTUserName then
    ' Found a message from the CurrentUser, so Get out! exit do
    else
    ' The message is not from the Current User, so let's Add it to the variable
    intNewMessages = intNewMessages + 1
    end if
    objRec.moveNext()
    loop

    if intNewMessages > 0 then
    ' if the are new messages, let's surround it with curve brackets
    if objRec.EOF then
    ' there are more than 20, so, instead of looping all we show +20
    strNewMessages = "(+" & intNewMessages & ")"
    else
    strNewMessages = "(" & intNewMessages & ")"
    end if
    strNewMessages = "(" & intNewMessages & ")"
    strScriptName = strScriptName & strNewMessages
    end if

    objRec.close
    set objRec = Nothing
    end if
    %>
Hope you find this useful

my Forum: www.ga-paneuropean.com





<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Average Member
kolucoms6
Posts: 845
845

Can you put/place the code to diaplay last 10 messages in left bar ?(I know you have to use active.asp kind of code)<
Posted
Average Member
modifichicci
Posts: 787
787
Remember that
SELECT TOP 20 doesn't work in mysql it needs LIMIT 20<
Posted
Forum Moderator
AnonJr
Posts: 5768
5768
Good catch. Best solution would probably be to use the TopSQL() function - its found in inc_func_common.asp.<
Posted
Junior Member
balexandre
Posts: 418
418
nice one AnonJr
updated !
(2 many functions and not that inside the core of the Forum code smile)

kolucoms6 I don't have it so you can modify, I will do it with documentation, it's a <TABLE> with all the info so you will need to know the code to get the best position on it.
to get my "layout" you need to change a lot in the original forum, cause it's tricky.
I can do something so you can ADD on top of the Forum or at Bottom, using for example 5 messages in a row and so you will have 2 rows with the last 10 messages...
do you need this? send me an email if you prefer (u can find it on the code, or use the Forum send email function).<
Posted
Starting Member
Target_Locked
Posts: 38
38
Hi Bruno Alexandre,
Could you show detailed instruction to implement your MOD. Such as which file, go to which line number? and how that line look like? and what ver of Snitz was tested? Thanks.<
Snitz 2000 Ver 3.4.06
Posted
Junior Member
balexandre
Posts: 418
418
well, this topic only concerns in showing how many messages since your last message, and the code it's here

for the Latest Top 10 messages, that I think that is what you are interest in, I need to pick up the code and implemented in a MOD, it's just one file and you include it where you need, right now, it's a vertical table, and the Snitz Forum as you know does not have that space at the forum left side... I had to edit the include header file for that effect, I will create a new topic with the file you need.
<
Posted
Starting Member
Target_Locked
Posts: 38
38
Originally posted by balexandre
well, this topic only concerns in showing how many messages since your last message, and the code it's here

for the Latest Top 10 messages, that I think that is what you are interest in, I need to pick up the code and implemented in a MOD, it's just one file and you include it where you need, right now, it's a vertical table, and the Snitz Forum as you know does not have that space at the forum left side... I had to edit the include header file for that effect, I will create a new topic with the file you need.

"Latest Top 10 messages"
That's what I am looking for. Hoping that your MOD will be released soon.<
Snitz 2000 Ver 3.4.06
Posted
Average Member
phy1729
Posts: 589
589
It already has been
http://forum.snitz.com/forum/topic.asp?TOPIC_ID=65954<
You Must enter a message