Author |
Topic |
Andy Humm
Average Member
United Kingdom
908 Posts |
Posted - 15 November 2007 : 07:09:00
|
I have had a good search and can not find a suitable mod that will give me an external text on my website showing the number of users online. There is a similar mod around that generates code, which extracts the last number of posts that have been posted ie Syndication Link Builder and we paste that code where the text needs displaying but ideally all I want displayed on my webpage is "There are currently xx number of people online in the forum" Any help/suggestions would be greatly appreciated..Andy |
|
balexandre
Junior Member
Denmark
418 Posts |
Posted - 15 November 2007 : 07:26:37
|
what do you mean by External text ?
the Mod says Active members: 8 Anonymous Members: 0 Guest: 5 Total: 13
and you can even see the current page where this users are...
once again, what do you mean by "External Text"
http://www.ga-paneuropean.com/gape/active_users.asp
|
Bruno Alexandre (Strøby, DANMARK)
"a Portuguese in Danmark"
|
|
|
Andy Humm
Average Member
United Kingdom
908 Posts |
Posted - 15 November 2007 : 07:43:57
|
External text: Is what I would like displayed away from the forum pages eg on my home page "There are xx people online at the moment in the forum" (where xx= total) |
|
|
balexandre
Junior Member
Denmark
418 Posts |
Posted - 15 November 2007 : 08:03:21
|
is the site and the forum in the same server??
if YES, you can always use Session variable for that! what MOD are you using? if NO, well, you need to pass info from one server to the other, you can do this in many ways, WebService, XML, Database, Etc...
what do you have so I can give you more help?
updated: I was seeing your Forum and it seams that you used it in the same server, so, you can even include it in the page and dont use Session variables, do this:
1. create a new file and paste this code
<!--#INCLUDE FILE="config.asp"-->
<!--#INCLUDE FILE="inc_func_common.asp"-->
<%
set my_Conn = Server.CreateObject("ADODB.Connection")
my_Conn.Errors.Clear
Err.Clear
my_Conn.Open strConnString
%>
<!--#INCLUDE FILE="inc_activeUsers.asp"-->
<%
my_Conn.close()
set my_Conn = nothing
%>
2. save as for example ActiveUsersTable.asp and then
3. include that code where you need in your page like<!--#INCLUDE FILE="forum/ActiveUsersTable.asp"-->
you can see this file in action here |
Bruno Alexandre (Strøby, DANMARK)
"a Portuguese in Danmark"
|
Edited by - balexandre on 15 November 2007 08:57:26 |
|
|
Andy Humm
Average Member
United Kingdom
908 Posts |
Posted - 15 November 2007 : 11:39:17
|
Thank you so far, I have site and forum on the same server, and an access db, I have created a test page http://www.lynehamvillage.com/insert.asp As you can see it is similar but the icons do not display..
Is there a way of extracting just the text " Members Online Total = 9" rather than using all the box. Any clues on a session variable would be great.. rgds andy
|
|
|
balexandre
Junior Member
Denmark
418 Posts |
Posted - 16 November 2007 : 11:40:55
|
it's easy
3 steps:
1. open file inc_activeUsers.asp 2. Find code arround line 101 intTotalActiveUsers = intTotalActiveUsers intActiveGuests and after that line paste this:application.Lock()
application("HowManyUsersInForum") = intTotalActiveUsers
application.UnLock() 3. Now, create a new file called, for example: ActiveUsersSentence.asp and paste this inside:<%
dim howmanyusers, phrase
howmanyusers = application("HowManyUsersInForum")
phrase= "There are currently <strong>{0}</strong> user(s) in the <a href=""forum/"">Forum</a>."
response.write( replace( phrase, "{0}", howmanyusers ) )
response.Flush()
%> change the word variable to the sentence you want
Now... include the file where you need, many times you want... Easy right?
hope it helps
P.S. test it here http://www.ga-paneuropean.com/gape/test2.asp
Note:
Of course you can use if as Inline code, without the include file, but it's always good to have an include file, you never know when you need to change and one change = changing it everywhere, but if you prefer the inline approach, just change the step 3 to
3. Add this code in the place you want to show the sentence:
<% =( replace( "There are currently <strong>{0}</strong> user(s) in the <a href=""forum/"">Forum</a>.", "{0}", application("HowManyUsersInForum")) ) %>
|
Bruno Alexandre (Strøby, DANMARK)
"a Portuguese in Danmark"
|
Edited by - balexandre on 16 November 2007 11:48:57 |
|
|
Andy Humm
Average Member
United Kingdom
908 Posts |
Posted - 16 November 2007 : 17:44:26
|
Bruno alias balexandre Firstly excellent support and I thank you for your assistance. Just to really put the icing on the cake, is it possible to generate the inline code in a javascript or other format, so that I can show the text in my home page, which is an html file I need to generate some code from this
<% =( replace( "There are currently <strong>{0}</strong> user(s) in the <a href=""forum/"">Forum</a>.", "{0}", application("HowManyUsersInForum")) ) %>
Incidentally, the Include file method sent my webpage - built under a template in dreamweaver potty, but the inline code is brill..
If you could help, you would certainly be spot on. rgds andy
|
|
|
Andy Humm
Average Member
United Kingdom
908 Posts |
Posted - 16 November 2007 : 17:54:32
|
Good input marshalmix and thank you both.. How would you alter the inline code to accommodate the two outputs ie members and guests
<% =( replace( "There are currently <strong>{0}</strong> user(s) in the <a href=""forum/""> Lyneham Village Forum</a>.", "{0}", application("HowManyUsersInForum")) ) %>
Apols but I am a novice at the coding stuff.. rgds andy |
|
|
Andy Humm
Average Member
United Kingdom
908 Posts |
Posted - 17 November 2007 : 01:55:33
|
Marshalmix, many thanks for your two replies above.. Firstly I have the inline code working on an asp extension page, but my website home page is .html. Can code be generated to show <%response.write "There are currently <strong>" & application("HowManyMembersInForum") + application("HowManyGuestsInForum") & "</strong> user(s) in the <a href=""forum/""> Lyneham Village Forum</a>."response.Flush()%> Forgive me if I am wrong by I thought the <%xxx ....%> only worked in asp. I have not tried the code yet but will this generate There are currently 86 user(s) in the forum (where green 8 is members and red 6 is guests) is there a way to separate the text to "There are currently 8 members and 6 guests viewing the forum" Secondly will the code you provided in green above here generate the output for the two factors ie members and guests kind regards andy
|
Edited by - Andy Humm on 17 November 2007 02:07:10 |
|
|
balexandre
Junior Member
Denmark
418 Posts |
Posted - 17 November 2007 : 03:55:14
|
You never happy right?
using the code pointed by MarshalMix with the 2 application variables do this:
1. create a new file called ActiveUsersSentence.asp
and paste this file content inside:
2. in your HTML code, put this inside the HEAD tag
<script src="test_js.asp" ></script>
3. and when you want to put the line, add this:
<script type="text/javascript"> getSentence(); </script>
Now you have a Javascript Code that you can add into a HTML page
you can see this working on this link: http://www.ga-paneuropean.com/gape/test3.asp
check the Source Code so you can see what's in the code. |
Bruno Alexandre (Strøby, DANMARK)
"a Portuguese in Danmark"
|
|
|
MarkJH
Senior Member
United Kingdom
1722 Posts |
Posted - 17 November 2007 : 06:52:29
|
Think this should generate the output you need, Andy.
Scratch all of that, it looks like Bruno's post should give you everything you need. |
Bandlink.net - http://www.bandlink.net/ Bandlink Music Forums - http://www.bandlink.net/forum/ |
Edited by - MarkJH on 17 November 2007 06:54:58 |
|
|
Andy Humm
Average Member
United Kingdom
908 Posts |
Posted - 17 November 2007 : 07:37:20
|
Bruno, I am more than happy in fact I can only praise you for the excellent help you have provided. I probably didn't explain the requirements fully in the onset. Thanks everso much again - works a treat!
|
|
|
balexandre
Junior Member
Denmark
418 Posts |
Posted - 17 November 2007 : 11:58:26
|
no worries Andy, as long you're happy
this was a easy question (after I knew what External Text was all about), there are always more than one way of doing things... now you have 3 |
Bruno Alexandre (Strøby, DANMARK)
"a Portuguese in Danmark"
|
|
|
thermal_seeker
Junior Member
United Kingdom
430 Posts |
Posted - 18 November 2007 : 04:58:50
|
is it possible to include this on a .NET 2.0 site ?? (.aspx)
Dave |
No good at coding, but I can plough a field !! |
|
|
balexandre
Junior Member
Denmark
418 Posts |
Posted - 18 November 2007 : 13:21:11
|
sure... same way, the output is JavaScript, so you can add to anything you want as long the browser support JavaScript and it's on |
Bruno Alexandre (Strøby, DANMARK)
"a Portuguese in Danmark"
|
|
|
Andy Humm
Average Member
United Kingdom
908 Posts |
Posted - 19 November 2007 : 16:51:16
|
balexandre, I wonder if you could solve a little error display that has occured since putting the above coding in. The script works as advertised, but someone has pointed out, that in the status line of IEbrowser there is Errors on Page, clicking the amber warning triange, it provides the following Error: 'response' is undefined Code:0 When you refresh the page the error clears, However when you move from this page and return, the error is back
I temporarily deleted the script from the page and the errors do not appear, reinstating the code the error returns. The code you kindly provided is incorporated in this url page www.lynehamvillage.com/index2.html It is the only page with your script and unfortunately the only one with this slight error..?? Original file prior to changes www.lynehamvillage.com/index.html
The html coding around the line 42 is as follows <script type="text/javascript">
//form tags to omit in NS6+: var omitformtags=["input", "textarea", "select"]
omitformtags=omitformtags.join("|")
function disableselect(e){ if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1) return false }
function reEnable(){ return true }
if (typeof document.onselectstart!="undefined") document.onselectstart=new Function ("return false") else{ document.onmousedown=disableselect document.onmouseup=reEnable } </script> Where line 42 is in red.
I am sure that this script is okay, as it is on all my other html and asp files on the domain and no errors occur. I am not sure where to go from here to alleviate this niggling error Any suggestions greatly appreciated.. rgds andy |
Edited by - Andy Humm on 19 November 2007 17:40:10 |
|
|
Topic |
|