|
-
Aug 29th, 2005, 09:27 PM
#1
Thread Starter
Fanatic Member
Include on Header plus link inside it
Hmm. Need help on designing a header (or even footer and navigator php files) that has a link that's not an absolute. A little explanation I guess should help.
Here's my scenario. I got a header.php to be included at index.php (home page) and also included at index.php (at catalog directory under /). So something like this
Code:
/
+ index.php (Includes header.php)
+ header.php
+ catalog/ (Directory catalog)
+ index.php (Includes header.php)
Header has a link for products that is <a href="catalog/">PRODUCTS</a>, so by the time the user clicks at PRODUCTS in index.php (home) it goes to catalog/index.php where includes a header with an <a href="catalog/">PRODUCTS</a>, so clicking the products there would give me a Not Found having a link like http://localhost/pcx/catalog/catalog/ where pcx is a project folder inside my localhost.
Hope to have my questions clear. Thanks in advance.
-
Aug 29th, 2005, 10:06 PM
#2
Hyperactive Member
Re: Include on Header plus link inside it
<?php
require ('header.php');
?>
-
Aug 29th, 2005, 10:07 PM
#3
Hyperactive Member
Re: Include on Header plus link inside it
i think tahts wat u want i dont really understand ur question could u explain better?
-
Aug 29th, 2005, 10:13 PM
#4
Thread Starter
Fanatic Member
Re: Include on Header plus link inside it
I can just <?php include "header.php"; ?> but then I'll explain a bit of a problem. Structure of my project is
Code:
/
+ index.php (includes header.php)
+ header.php
+ catalog/ (directory)
+ index.php (includes ../header.php)
At header.php there's a link <a href="catalog/">PRODUCTS</a>, so at index.php (home, not the catalog directory) I can go to catalog/index.php buy just clicking it. Now at index.php (now in the catalog directory) the link <a href="catalog/">PRODUCTS</a> is still there because it is included from header.php. So clicking the link at index.php (now in the catalog directory) will give me a 404 because there is no catalog folder in the catalog folder.
How do I design this thing? I mean I need help on placing things. Where should I place what and what should I place where?
-
Aug 30th, 2005, 08:11 AM
#5
PowerPoster
Re: Include on Header plus link inside it
Its something thats bothered me for quite a while... but my dodgy solution is,
For something in the root dir.
Code:
$currdir = ".";
Header.php----
print "<a href=\"" . $currdir . "/link\">";
So if you were in the catalog directory, then you would make $currdir ".." I do believe. So just have the variable at the top of the page and it'll work. I think you could probably do it using some of the super global variables as well.. figure out the location of the current file and then if needed add a "../"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|