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)
 MOD: Jump/Label Forum Code addition
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

madfiddler
Starting Member

United Kingdom
33 Posts

Posted - 28 November 2003 :  06:10:04  Show Profile
This is quite a simple MOD but one I have found particularly useful. It allows members to place links in their posts to other locations in the same post. This is implented using hyperlinks and named destination anchors.

I have found this very useful when using a forum as a "knowlege base" in which members can write potentially long posts. The new forum code can be used to create a sort of table of contents at the top of the post and when they click on the items in the contents it then jumps further down to the appropriate point in the post.

the new forums code to insert a link is...
[jump label="LabelName"]My Link[/jump]


and then the label to jump to is defined as
[label="LabelName"]



There is one issue that I can think of that would cause problems, so if anyone would like to suggest a fix then please do!. The problem is if in a reply to a post a member reuses the same label name that was in the original topic. This would cause a problem when both posts are displayed on the same page. This could also occur if someone replied quoting a post that contained the labels. So any solutions to this would be appreciated!



Here are the changes that need to be made...


In inc_func_posting.asp between the 'end function' and 'function CleanCode...' add the following code


' #### start: madfiddler JUMP in post MOD

function doCodeJump(msgString)
	sStr = "<a href=""#"
	Pos = Instr(1, msgString, sStr, 1)
	While (Pos > 0)
		msgString = Left(msgString, Pos - 1) & "[jump label=""" & Right(msgString, Len(msgString) - Pos - 9)
		sStr = """>"
	        Pos = Instr(Pos, msgString, sStr, 1)
		msgString = Left(msgString, Pos - 1) & """]" & Right(msgString, Len(msgString) - Pos - 1)
		sStr = "</a>"
		Pos = Instr(Pos, msgString, sStr, 1)
		msgString = Left(msgString, Pos - 1) & "[/jump]" & Right(msgString, Len(msgString) - Pos - 3)
		sStr = "<a href=""#"
		Pos = Instr(Pos, msgString, sStr, 1)
	Wend
	doCodeJump = msgString
end function

function doCodeLabel(msgString)
        sStr = "<a name="""
	Pos = Instr(1, msgString, sStr, 1)
	While (Pos > 0)
		msgString = Left(msgString, Pos - 1) & "[label=""" & Right(msgString, Len(msgString) - Pos - 8)
		sStr = """>"
		Pos = Instr(Pos, msgString, sStr, 1)
		msgString = Left(msgString, Pos - 1) & """]" & Right(msgString, Len(msgString) - Pos - 1)
		sStr = "</a>"
		Pos = Instr(Pos, msgString, sStr, 1)
		msgString = Left(msgString, Pos - 1) & Right(msgString, Len(msgString) - Pos - 3)
	        sStr = "<a name="""
		Pos = Instr(Pos, msgString, sStr, 1)
	Wend
	doCodeLabel = msgString
end function

' #### end: madfiddler JUMP in post MOD



In inc_func_posting.asp and within the CleanCode function immediately after the first occurence of 'if strAllowForumCode = "1" then' insert the following code


' #### start: madfiddler JUMP in post MOD
fString = doCodeJump(fString)
fString = doCodeLabel(fString)
' #### end: madfiddler JUMP in post MOD



Within inc_func_common.asp find the function chkString and this piece of code which as at the end of the function

		
                end if
	end if
	if fField_Type <> "hidden" and _
	fField_Type <> "preview" then
		fString = Replace(fString, "'", "''")
	end if
	chkString = fString
end function


immediately before this add the following


' #### start: madfiddler JUMP in post MOD
fString = doCode(fString, "[jump label=""","""]","<a href=""#",""">")
fString = replace(fString, "[/jump]", "</a>", 1, -1, 1)
fstring = doCode(fString, "[label=""", """]", "<a name=""", """></a>")
' #### end: madfiddler JUMP in post MOD





  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.22 seconds. Powered By: Snitz Forums 2000 Version 3.4.07