WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-29-2006, 04:43 AM
WomenXtra WomenXtra is offline
WebProWorld Member
 

Join Date: Jan 2006
Location: London
Posts: 77
WomenXtra RepRank 0
Default Help with Relative paths + navigation - php template pages

Hi All,

i have searched online in every tutorial and many forums and I am still struggling to find a solution to my problem. How do I go about solving this please let me know!

I need to design a menu file which I can use across all the website. The file has links on it which takes the visitor to different directories so the structure of the links are like this:

index.php
/categoryone/main.php
/categorytwo/main2.php

and so on.

when I include the html file into the php pages, and I click on the links through the category (subdirectory) files, the links dont work. simply because the links tends to add the directory name on top of the link path already showing in the menu.

so it shows something like this:
/categoryone/categoryone/main.php

am not too sure what do i need?
is there a script? or some code that can dynamically change the urls of the menu to to enable them to work?

please help - i am very stuck!

thanks,
T

ps: could you please post an example how to go about solving this?
__________________
www.womenxtra.co.uk
Join our new community and take part in the discussions!
Reply With Quote
  #2 (permalink)  
Old 08-29-2006, 11:25 AM
arvana's Avatar
arvana arvana is offline
WebProWorld Pro
 

Join Date: Jul 2003
Location: Guelph, Ontario, Canada
Posts: 157
arvana RepRank 0
Default

Well one solution that comes to mind is simply to leave the folder name off of the link in your include file....

It's hard to answer a question like this without seeing the code itself, and how you are implementing it. It is SSI, PHP, or ...? Please post a link to the site, and the relevant code, so we can have a look.
__________________
Arvana
arvanadesign.com
Reply With Quote
  #3 (permalink)  
Old 08-29-2006, 02:31 PM
cyanide cyanide is offline
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Location: Toronto, Canada
Posts: 2,193
cyanide RepRank 0
Default

Yes, that's one of the problems with using relative urls.

There are a couple ways to achieve this.
a) By extending your use of php and create some variables, specifically one that will be assigned to your domain
eg) $home-page = http://www.domain.com
Then your urls will look like this
Code:
<a href ="<? echo $home-page; ?> /somepage.php">
b) You can also try using the base href tag, which would point to your domain also
__________________
|
Web Hosting Guru
| Need Help For Your Forum?
Reply With Quote
  #4 (permalink)  
Old 08-30-2006, 11:35 AM
WomenXtra WomenXtra is offline
WebProWorld Member
 

Join Date: Jan 2006
Location: London
Posts: 77
WomenXtra RepRank 0
Default

that worked

thanks a lot :))))

i love this place.
__________________
www.womenxtra.co.uk
Join our new community and take part in the discussions!
Reply With Quote
  #5 (permalink)  
Old 08-30-2006, 11:44 AM
cyanide cyanide is offline
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Location: Toronto, Canada
Posts: 2,193
cyanide RepRank 0
Default

no problem

which one worked?
__________________
|
Web Hosting Guru
| Need Help For Your Forum?
Reply With Quote
  #6 (permalink)  
Old 09-05-2006, 04:54 PM
crdesign crdesign is offline
WebProWorld New Member
 

Join Date: Sep 2006
Posts: 14
crdesign RepRank 0
Default

This is why I never use relative urls or paths. With a relative path you must edit every instance of that code if you decide later to change a directory name or move the file somewhere else. With an absolute path this becomes less likely and your code is more portable. Especially if you code using variables in place of things like domain names, etc which may change if your code moves.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: help, navigation, pages, paths, php, relative, template



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Search Engine Friendly URLs by vBSEO 3.0.0