| relative links in included navigation | |
|---|---|
| Tweet Topic Started: Oct 9 2008, 05:04 AM (76 Views) | |
| bustya | Oct 9 2008, 05:04 AM Post #1 |
![]()
The Master Bitchslapper
|
There might be a better way to do this, but this is what I'm doing. Create a file for each directory that users would navigate to, examples: root.php mail.php network.php in each of those files write the relative paths to files: in root.php: $img = 'img/'; $mail = 'mail/'; $home= ''; in mail.php: $img = '../img/'; $mail = ''; $home= '../'; Then include the appropriate "relative links page" at the top of your pages. So in your index page you'll include root.php, in each of your PM pages you'll include mail.php. Then you can use the variables in your included menu: <? echo "<a href='".$mail."inbox.php'>"; ?>Inbox</a> ...which will naturally come after the included "relative links" so you'll be able to navigate through various directories with relative links. Simple. ABOUT INCLUDES Relative paths to includes is NOT safe, you need to define the full path: so instead of this: include ("includes/session.php"); do this: include("/usr/home/username/public_html/includes/session.php"); |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Other · Next Topic » |






12:49 AM Jul 11