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)
 Display Page Titles
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Caspoory
Starting Member

United Kingdom
18 Posts

Posted - 10 March 2002 :  11:29:24  Show Profile  Visit Caspoory's Homepage
I spent sometime yesterday coding an ASP script to display the right page title on the title bar. I did it and it worked perfectly

But then I though that this will slow down the page loading and the server, as the script calls the server/database to get the forum and topic title. So I though how about doing it after the page actually loads, i.e. instead of hitting the database twice in every page to get the title first and to get the proper topic/replies or listing of topics afterwards, just get the title after the page loads, which is already stored in a variable.

So I wrote a javascript to be excuted at the end of the page without hitting the server again. The advantage of doing this is that the server/database will not be hit upon twice, and the loading of the page will be normal as the javascript will be excuted on client side (which if running a good machine and internet line will not feel a differece)!

But the down side is that the script will not work on Netscape 4.x .

Anyhow, I found out later that the ASP script I wrote, which I will not use because I prefer the JavaScript even though it doesn't work on NS 4.x, is already available . I hate to re-invent the wheel

So, here is my script (JavaScript) that is already adapting for many MODs, and you can add more if you like. It should show a page title for all the admin pages, topics, forums, events, links, active..., bookmarks, profile, guestbook, etc. You name it

Just add the script/code TO THE END of inc_footer.asp, that's all.

Download the Code: http://www.ipsuk.com/swap/page_title_js_mod.js

However, if you want the ASP script for the page title it is here:
http://forum.snitz.com/forum/topic.asp?ARCHIVE=true&TOPIC_ID=16357



<% '############# Page Title JS Mod ##############################################
'## Copy the code and paste it at the END of the inc_footer.asp page
'## Customise the code according to the MODs you have installed
'## The code has been tested and worked successfully on IE 4.0+ , Netscape 6.0+
'## It also worked successfully on NetCaptor 7.0b2 with IE6
'## The script DOES NOT WORK on Netscape 4.x, Opera 4.02 - 6.01
'## By Caspoory 10 March 2002
'##############################################################################
aryScriptName = Split(Request.ServerVariables("SCRIPT_NAME"), "/")
strScriptName = aryScriptName(UBound(aryScriptName))
%>

<script language="JavaScript" type="text/javascript">
<!-- hide from older browsers
var scriptName = '<%= strScriptName %>'
var pageTitle = document.title
var titleSep = ' -'
var catTitle = '<%= Request.QueryString("Cat_Title") %>'
var forumTitle = '<%= trim(ChkString(Forum_Subject,"display")) %>'
var topicTitle = '<%= trim(ChkString(Topic_Subject,"title")) %>'
var whichPage = '<%= Request.QueryString("whichpage") %>'
var catSubject = '<%= Request.QueryString("cat") %>'
var parentSubject = '<%= Request.QueryString("parent_name") %>'
var subCatSubject = '<%= Request.QueryString("sub_name") %>'
var archive = '<%= Request.QueryString("ARCHIVE") %>'

if (scriptName.indexOf("admin_") == 0) {
pageTitle += titleSep + ' Administration'
}

if (catTitle != '') pageTitle += titleSep + ' ' + catTitle
if ((forumTitle != '' || topicTitle != '') && scriptName.indexOf("active.asp") != 0) {
if (forumTitle != '') pageTitle += titleSep + ' ' + forumTitle
if (topicTitle != '') pageTitle += titleSep + ' ' + topicTitle
} else {
forumTitle = '<%= Request.QueryString("Forum_Title") %>'
topicTitle = '<%= Request.QueryString("Topic_Title") %>'
if (forumTitle != '') pageTitle += titleSep + ' ' + forumTitle
if (topicTitle != '') pageTitle += titleSep + ' ' + topicTitle
}

if (scriptName.indexOf("policy") == 0 || scriptName.indexOf("register") == 0) {
pageTitle += titleSep + ' Registration'
} else if (scriptName.indexOf("profile") >= 0) {
pageTitle += titleSep + ' Profile'
} else if (scriptName.indexOf("members") >= 0) {
pageTitle += titleSep + ' Members'
} else if (scriptName.indexOf("recent.asp") == 0) {
pageTitle += titleSep + ' Recent Topics'
} else if (scriptName.indexOf("active.asp") == 0) {
pageTitle += titleSep + ' Active Topics'
} else if (scriptName.indexOf("active_users.asp") == 0) {
pageTitle += titleSep + ' Active Users'
} else if (scriptName.indexOf("activeusers") >= 0) {
pageTitle += titleSep + ' Active Users'
} else if (scriptName.indexOf("active_polls.asp") == 0) {
pageTitle += titleSep + ' Active Polls'
} else if (scriptName.indexOf("search") == 0) {
pageTitle += titleSep + ' Search'
} else if (scriptName.indexOf("subscription") == 0) {
pageTitle += titleSep + ' Subscriptions'
} else if (scriptName.indexOf("bookmark") == 0) {
pageTitle += titleSep + ' Bookmarks'
} else if (scriptName.indexOf("faq") >= 0) {
pageTitle += titleSep + ' FAQ'
} else if (scriptName.indexOf("poll") >= 0) {
pageTitle += titleSep + ' Poll'
} else if (scriptName.indexOf("pm_") == 0 ||
scriptName.indexOf("private") == 0 ||
scriptName.indexOf("pmmaint") >= 0) {
pageTitle += titleSep + ' Private Messages'
} else if (scriptName.indexOf("post.asp") == 0) {
var method = '<%= Request("method") %>'
var len = method.length
var poll = '<%= Request("poll") %>'
if (poll == '1'){
if (method.indexOf("Edit") == 0) pageTitle += titleSep + ' Edit Poll'
else pageTitle += titleSep + ' New Poll'
} else if (method.indexOf("Edit") == 0) {
method = method.substr(4,len-4)
pageTitle += titleSep + ' Edit ' + method
} else {
pageTitle += titleSep + ' New ' + method
}
} else if (scriptName.indexOf("events") == 0) {
pageTitle += titleSep + ' Events Calendar'
var mode = '<%= Request("mode") %>'
if (mode == 'add') pageTitle += titleSep + ' Add Event'
else if (mode == 'edit') pageTitle += titleSep + ' Edit Event'
} else if (scriptName.indexOf("guestbook") >= 0) {
pageTitle += titleSep + ' Guestbook'
var action = '<%= Request("action") %>'
if (action == 'sign') pageTitle += titleSep + ' Sign it'
else if (action == 'view') pageTitle += titleSep + ' View it'
} else if (scriptName.indexOf("links") >= 0) {
pageTitle += titleSep + ' Links Directory'
if (catSubject != '') pageTitle += titleSep + ' ' + catSubject
if (parentSubject != '') pageTitle += titleSep + ' ' + parentSubject
if (subCatSubject != '') pageTitle += titleSep + ' ' + subCatSubject
if (scriptName.indexOf("add_") > 0) pageTitle += titleSep + ' Add URL'
else if (scriptName.indexOf("addnewsubcat") > 0) pageTitle += titleSep + ' New SubCategory'
else if (scriptName.indexOf("addnew") > 0) pageTitle += titleSep + ' New Category'
else if (scriptName.indexOf("new") > 0) pageTitle += titleSep + ' New Links'
else if (scriptName.indexOf("popular") > 0) pageTitle += titleSep + ' Popular Links'
else if (scriptName.indexOf("toprated") > 0) pageTitle += titleSep + ' Top Rated'
else if (scriptName.indexOf("search") > 0) pageTitle += titleSep + ' Search'
else if (scriptName.indexOf("browse") > 0) pageTitle += titleSep + ' Browse Links'
else if (scriptName.indexOf("edit") > 0) pageTitle += titleSep + ' Edit/Delete'
} else if (scriptName.indexOf("system") >= 0) {
pageTitle += titleSep + ' Main Forum'
} else if (scriptName.indexOf("features") >= 0) {
pageTitle += titleSep + ' Features'
} else if (scriptName.indexOf("ranks") >= 0) {
pageTitle += titleSep + ' Ranking'
} else if (scriptName.indexOf("datetime") >= 0) {
pageTitle += titleSep + ' Date/Time'
} else if (scriptName.indexOf("email") >= 0) {
pageTitle += titleSep + ' Email'
} else if (scriptName.indexOf("colors") >= 0) {
pageTitle += titleSep + ' Colors'
} else if (scriptName.indexOf("badwords") >= 0) {
pageTitle += titleSep + ' Bad Words'
} else if (scriptName.indexOf("moderators") >= 0) {
pageTitle += titleSep + ' Moderators'
} else if (scriptName.indexOf("variable_info") >= 0) {
pageTitle += titleSep + ' Variables Info'
} else if (scriptName.indexOf("admin_info") >= 0) {
pageTitle += titleSep + ' Server Info'
} else if (scriptName.indexOf("mod_") >= 0) {
pageTitle += titleSep + ' MOD Setup'
} else if (scriptName.indexOf("ban_ip") >= 0) {
pageTitle += titleSep + ' Ban IP'
} else if (scriptName.indexOf("pending") >= 0) {
pageTitle += titleSep + ' Members Pending'
} else if (scriptName.indexOf("activity") >= 0) {
pageTitle += titleSep + ' Activity'
} else if (scriptName.indexOf("variable_info") >= 0) {
pageTitle += titleSep + ' Variables Info'
} else if (scriptName.indexOf("topics") >= 0) {
pageTitle += titleSep + ' Topics'
} else if (scriptName.indexOf("forums") >= 0) {
pageTitle += titleSep + ' Forums'
} else if (scriptName.indexOf("count") >= 0) {
pageTitle += titleSep + ' Update Count'
} else if (scriptName.indexOf("access_control") >= 0) {
pageTitle += titleSep + ' Access Control'
}
if (whichPage != '') pageTitle += titleSep + ' Page ' + whichPage
if (archive == 'true') pageTitle += ' (Archive)'

document.title = pageTitle

// done hiding -->
</script>
<!-- ############ END Page Title JS Mod ###################################### -->




A.Mosa : IPS Studio :: iNCiA

Edited by - caspoory on 10 March 2002 18:35:30

Edited by - caspoory on 11 March 2002 04:23:37

crash
Advanced Member

Netherlands
2064 Posts

Posted - 10 March 2002 :  18:27:24  Show Profile  Visit crash's Homepage
err... maybe you could post a link to a .txt file next time?

the code looks good though! i especially like this sentence here:

"It should work on most IE browsers 5.0+ or maybe even 4.0+
It could also work on Netscape 6.0 BUT NOT Netscape 4.x"





Crash's Site | Crash is from
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 10 March 2002 :  18:35:32  Show Profile  Visit Gremlin's Homepage
Nice script, easy to follow and edit to suit all the pages I have outside just the basic forum also.

www.daoc-halo.com
Go to Top of Page

Caspoory
Starting Member

United Kingdom
18 Posts

Posted - 10 March 2002 :  18:41:52  Show Profile  Visit Caspoory's Homepage
quote:

err... maybe you could post a link to a .txt file next time?


I added a link to a js file
quote:

the code looks good though! i especially like this sentence here:

"It should work on most IE browsers 5.0+ or maybe even 4.0+
It could also work on Netscape 6.0 BUT NOT Netscape 4.x"


Well, that's because I did it at home and I don't have a test environment here where I can test it on all the browser, as you usually need to do for JavaScripts.

I will test it tomorrow from work though and will let you know which browsers it does work on and which doesn't.



A.Mosa : IPS Studio :: iNCiA
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 10 March 2002 :  20:26:10  Show Profile  Visit Gremlin's Homepage
Netscape 6.2 - Works ok
Opera 6.01 - Half works, briefly flashes up title then reverts to whatever is in the <TITLE> tags.
NetCaptor 7.0b2 with IE6 - Works Ok

Thats all I've got installed currently, dont have anything earlier installed since I did my last reinstall of my dev PC.

www.daoc-halo.com
Go to Top of Page

Caspoory
Starting Member

United Kingdom
18 Posts

Posted - 11 March 2002 :  04:17:55  Show Profile  Visit Caspoory's Homepage
quote:

Netscape 6.2 - Works ok
Opera 6.01 - Half works, briefly flashes up title then reverts to whatever is in the <TITLE> tags.
NetCaptor 7.0b2 with IE6 - Works Ok



Thanks, for the info Gremlin.

Yes, I've seen how Opera behaves and its wierd! Anyway, it did that in Opera 5.11 as well. Opera 4.02 did not work at all though.

Netscape 6.0+ Works fine as you said.

IE4.0+ works fine too.



A.Mosa : IPS Studio :: iNCiA
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 11 March 2002 :  05:21:38  Show Profile  Visit Gremlin's Homepage
Your welcome, I've put the script straight up on my site and its running great :) thanks for sharing it.

www.daoc-halo.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.15 seconds. Powered By: Snitz Forums 2000 Version 3.4.07