Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/Code)
 Show how many messages since yours IN PAGE TITLE
 New Topic  Reply to Topic
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

balexandre
Junior Member

Denmark
418 Posts

Posted - 26 May 2007 :  06:16:47  Show Profile  Visit balexandre's Homepage  Send balexandre an ICQ Message  Reply with Quote
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:
    <title>
    (so, search for
    <title>
    , the 2nd one STOP and scroll up until you get the response.write, above that line, paste the include)

    paste this:

    %><!--#INCLUDE FILE="inc_showMsgNrOnTitle.asp"><%

  • in a new file called
    inc_showMsgNrOnTitle.asp

    paste this:

    <%
    ' ********************************************************************************************
    ' 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




www.ga-paneuropean.com/gape.v2/ajuda/NrMoreMessages2.gif" border="0">


www.ga-paneuropean.com/gape.v2/ajuda/NrMoreMessages.gif" border="0">


<

Bruno Alexandre
(Strøby, DANMARK)

"a Portuguese in Danmark"



Edited by - balexandre on 10 July 2008 15:58:18

AnonJr
Moderator

United States
5765 Posts

Posted - 26 May 2007 :  06:43:21  Show Profile  Visit AnonJr's Homepage  Reply with Quote
Is it something you have to be logged in to see?<
Go to Top of Page

balexandre
Junior Member

Denmark
418 Posts

Posted - 26 May 2007 :  07:05:31  Show Profile  Visit balexandre's Homepage  Send balexandre an ICQ Message  Reply with Quote
only logged in you will be able to see that, cause... How can the MOD know who you are to tell you how many new messages are since your last one?

<

Bruno Alexandre
(Strøby, DANMARK)

"a Portuguese in Danmark"


Go to Top of Page

AnonJr
Moderator

United States
5765 Posts

Posted - 26 May 2007 :  07:19:16  Show Profile  Visit AnonJr's Homepage  Reply with Quote
You could do like active.asp does - if you're not logged in it shows all the active topics for the last 30 days. Likewise, if not logged in you could have the number of topics for the last 30 days. Or you could just provide a generic login so we can see it in action.

Also, these forums (as in here, not in the actual base code) have a neat little undocumented feature - [scrollcode] tags. It was added so you could post huge chunks of code like that without stretching the posts. Just a friendly tip. <

Edited by - AnonJr on 26 May 2007 07:20:54
Go to Top of Page

balexandre
Junior Member

Denmark
418 Posts

Posted - 26 May 2007 :  07:36:47  Show Profile  Visit balexandre's Homepage  Send balexandre an ICQ Message  Reply with Quote
didn't know about scrollcode done !

humm... It's a nice ideia, but I can do that for yourself and show the code, I don't thing I'll used it cause... if you're not login, just click the Active posts link

the Objective is 2 be logged in and minimize the window or put the window in a new tab, and soon someone put's a message you can see it right away

but if you want I can add that feature! to many years under ASP / T-SQL... that's simple to implement.

By the way,

do you think I should put here the code for the Top 10 Messages MOD that I created in the forum?<

Bruno Alexandre
(Strøby, DANMARK)

"a Portuguese in Danmark"



Edited by - balexandre on 26 May 2007 07:50:12
Go to Top of Page

AnonJr
Moderator

United States
5765 Posts

Posted - 26 May 2007 :  08:44:58  Show Profile  Visit AnonJr's Homepage  Reply with Quote
quote:
Originally posted by balexandre

didn't know about scrollcode done !

Glad to help.

quote:
Originally posted by balexandre

humm... It's a nice ideia, but I can do that for yourself and show the code, I don't thing I'll used it cause... if you're not login, just click the Active posts link

the Objective is 2 be logged in and minimize the window or put the window in a new tab, and soon someone put's a message you can see it right away

I kinda figured that. It was just a thought.


quote:
Originally posted by balexandre

By the way,

do you think I should put here the code for the Top 10 Messages MOD that I created in the forum?

Sure. We try to encourage everybody post back fun code like that - it helps the community grow. <
Go to Top of Page

balexandre
Junior Member

Denmark
418 Posts

Posted - 26 May 2007 :  08:52:48  Show Profile  Visit balexandre's Homepage  Send balexandre an ICQ Message  Reply with Quote
just added some pictures so everyone knows what's the propose of this code <

Bruno Alexandre
(Strøby, DANMARK)

"a Portuguese in Danmark"


Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 26 May 2007 :  09:51:35  Show Profile  Reply with Quote

Is it ready to download as a single file ?<
Go to Top of Page

balexandre
Junior Member

Denmark
418 Posts

Posted - 26 May 2007 :  10:23:42  Show Profile  Visit balexandre's Homepage  Send balexandre an ICQ Message  Reply with Quote
Now you lost me ...

single file?

all you need to do is copy that code in the scrolling window into a new file and rename it, saving into your forum root directory where all the forum files are, then search inside inc_header.asp for the second <title> and include that line above the response.write function for that 2nd <title><

Bruno Alexandre
(Strøby, DANMARK)

"a Portuguese in Danmark"



Edited by - balexandre on 26 May 2007 10:28:05
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 26 May 2007 :  10:38:46  Show Profile  Send ruirib a Yahoo! Message  Reply with Quote
You should make it clear that this is supported only in SGBDs that support UNION queries, which excludes MySQL versions previous to 4.x. Also, the images posted are a bit misleading, since the code will only change the title of the page in a normal base Snitz version.

As a comment not meant to be seen in a negative light, the current code can be quite inefficient, since it needs to navigate through all the records to find out the total number of new posts. You could use the current UNION query as subquery of a new query just to count the number records returned by the UNION query and then just retrieve the returned value.

As an alternative, two SELECT COUNT(*) queries, one for the topics, another for replies, would do it too. This latter option would even be available to MySQL 3.x databases.<


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

balexandre
Junior Member

Denmark
418 Posts

Posted - 26 May 2007 :  10:41:13  Show Profile  Visit balexandre's Homepage  Send balexandre an ICQ Message  Reply with Quote
never used mySQL, and I do not know what are the differences on t-sql, my world is only MS SQL

please fell free to update a T-SQL Code

about looping, yes, but my Access Database knowledge is limited and only led me to that, in MS SQL, I would use an SP, retrieve both count and sum ... easy, but not supported by Access.

But: I changed the code, so now I request the TOP 20 and if more than 20 I simple say (+20) instead of looping all the messages in the Database... this was a really issue if the user is a new member and not yet any posts <Obrigado!>

As suggested, I will edit my post and add that message about UNION function

about the images... humm, I even added "Objective", the Top 10 messages is other MOD that I created, and like AnonJR said, I will post it as well, but right now it's codded for my Forum, and no comments or other options as 1 vertical table with all 10 messages.

to place the MOD I should, at least, place some options, like Vertical / Horizontal and how many Rows / Columns<

Bruno Alexandre
(Strøby, DANMARK)

"a Portuguese in Danmark"



Edited by - balexandre on 26 May 2007 10:58:39
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 27 May 2007 :  11:30:42  Show Profile  Reply with Quote

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)<
Go to Top of Page

modifichicci
Average Member

Italy
787 Posts

Posted - 27 May 2007 :  11:58:54  Show Profile  Visit modifichicci's Homepage  Reply with Quote
Remember that
SELECT TOP 20 doesn't work in mysql it needs LIMIT 20<

Ernia e Laparocele
Forum di Ernia e Laparocele
Acces - MySql Migration Tutorial
Adamantine forum
Go to Top of Page

AnonJr
Moderator

United States
5765 Posts

Posted - 27 May 2007 :  14:32:51  Show Profile  Visit AnonJr's Homepage  Reply with Quote
Good catch. Best solution would probably be to use the TopSQL() function - its found in inc_func_common.asp.<
Go to Top of Page

balexandre
Junior Member

Denmark
418 Posts

Posted - 29 May 2007 :  07:00:08  Show Profile  Visit balexandre's Homepage  Send balexandre an ICQ Message  Reply with Quote
nice one AnonJr

updated !

(2 many functions and not that inside the core of the Forum code )

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).<

Bruno Alexandre
(Strøby, DANMARK)

"a Portuguese in Danmark"



Edited by - balexandre on 29 May 2007 07:12:38
Go to Top of Page

Target_Locked
Starting Member

Vietnam
38 Posts

Posted - 07 November 2007 :  22:32:40  Show Profile  Reply with Quote
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

Edited by - Target_Locked on 07 November 2007 22:49:17
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.2 seconds. Powered By: Snitz Forums 2000 Version 3.4.07