Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How sites display Location of where you have been

Status
Not open for further replies.

h2oski

Programmer
Nov 15, 2001
8
0
0
US

Hi,

I was wondering how some some sites are able to keep track of were you have in the site.
For example, I have seen some sites have on the top of the page: Location: Home > FAQs > Search
Each one of the items are hyperlinks, so you can get back to were you started easy.

Anybody know how they do this?

Bill
 
that's just a navigational structure from the path you took to get there with the referer server variable most likely. either that or you can be long winded and use session variables to track the path in which the user visited last and thus create your dynamic nav bar _________________________________________________________
for the best results to your questions: FAQ333-2924
[sub]01001111 01101110 01110000 01101110 01110100[/sub]
onpnt2.gif
[sup] [/sub]
 

I think that sounds right that they probably are using server variables. It seems like you have to store the SV in a string or hold it some where. Then you would redisplay it. I am just not sure.
 
You use this code to show the visitors IP and previous page visited, the info does indeed come from the server variables


Hello visitor from <%= Request.ServerVariables(&quot;REMOTE_ADDR&quot;) %>!
You arrived here from <%= Request.ServerVariables(&quot;HTTP_REFERER&quot;) %>.


Chris.
Indifference will be the downfall of mankind, but who cares?
 
Or you can cheat like I do and only display the crumbs for the nav bar for the most probable pth the user has taken :)

The problem with tracking this in a variable is that at some point the user will (hopefully) get 15 clicks into your website, and your crumbs will start to repeat...
and then they will throw your formatting off,
and then they will line wrap,
and then..well, you get the picture.

Tracking probable path over definate path is much easier as you don't need to worry about repeating links and so on.

You can hardcode in all the links and such, but I found it gets to be a pain when you try to change the look of them or the spacing or whatever. Just because I am tired from work and feel like giving away free stuff here is a copy of the object I write at some point to make creating and displaying crumbs a much easier chore:
Code:
Class NavCrumbList
	Dim nextCrumbList
	Dim myCrumbAddress, myCrumbText

	Public Property Let Address(addr)
		myCrumbAddress = addr
	End Property

	Public Property Get Address
		Address = myCrumbAddress
	End Property

	Public Property Let Text(txt)
		myCrumbText = txt
	End Property

	Public Property Get Text
		Text = myCrumbText
	End Property

	Public Function ToString()
		If isEmpty(nextCrumbList) Then
			ToString = &quot;<a href=&quot;&quot;&quot;&myCrumbAddress&&quot;&quot;&quot;>&quot;&myCrumbText&&quot;</a>&quot;
		Else
			ToString = &quot;<a href=&quot;&quot;&quot;&myCrumbAddress&&quot;&quot;&quot;>&quot;&myCrumbText&&quot;</a> » &quot; & nextCrumbList.ToString
		End If
	End Function

	Public Function AddCrumb(addr,txt)
		If isEmpty(myCrumbText) Then
			myCrumbAddress = addr
			myCrumbText = txt
		ElseIf isEmpty(nextCrumbList) Then
			Set nextCrumbList = New NavCrumbList
			nextCrumbList.AddCrumb addr, txt
		Else
			nextCrumbList.AddCrumb addr, txt
		End If
	End Function

	Public Function GetLastText()
		If isEmpty(nextCrumbList) Then
			GetLastText = myCrumbText
		ElseIf isEmpty(nextCrumbList.Text) Then
			If isEmpty(myCrumbText) Then 
				GetLastText = &quot;Page Error.&quot;
			Else
				GetLastText = myCrumbText
			End If
		Else
			GetLastText = nextCrumbList.GetLastText
		End If
	End Function
End Class

Here's how it works. First instantiate a copy of it:
Code:
Dim nav
Set nav = New NavCrumbList

Now wherever you want to add a crumb to it in this page you can simply call the nav.AddCrumb(address as string,text as string)

Then when you want to output it just call the toString method. Feel free to alter the formatting in the toString or gnore this object altogether :) [sub]01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101 [/sub]
[sup]29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19[/sup]
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
That's quite ingenious Tarwn.
I just used the server vars to write a visitor tracking system for MySQL cos I feel aggrieved at paying for something I can do just as well! (cheapskate!)

Chris.

Indifference will be the downfall of mankind, but who cares?
 
ingenious Tarwn

WOW! when I grow up I want to be like Tarwn

[lol]

No really, that's pretty cool Tarwn. [smile] _________________________________________________________
for the best results to your questions: FAQ333-2924
[sub]01001111 01101110 01110000 01101110 01110100[/sub]
onpnt2.gif
[sup] [/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top