I know how to do just about everything I need, the problem I'm running into is the sub directories.
For example: Nav.php is in the root directory. Index.php
is also in the root directory. Now I want to go to a page about cats, located at about/cats.php
.
When I want to go from about/cats.php
to blog/kittens.php
how would I structure the links?
<a href="about/cats.php">cats</a>
would take me to about/cats just fine from the root directory. But if I'm on the blog/kittens.php
page, I'd get a link like about/blog/kittens.php
.
It's not something that needs massive/dynamic arrays or anything, I've just had a hard time wrapping my head around the cleanest way to do this.
How can I keep one navigation file but still have correct links even if I'm 2 or 4 levels from the root? I've seen others use sql databases (if that's the best way I don't mind), but I feel like that's too complicated and I'm just missing a much easier method.
If you add / (Slash) in starting of href it would be considered from root. For example if you are in cats.php page and want to have access to your blog/kitten page so make href like this.
<a href="/blog/kittens.php">Kittens</a>
the way to go about is have navbar/sidebar
with absolute urls
, so that it can be used any where on your site along with index page.
menu can have links like
<a href="/blog/kittens.php">Kittens</a>
<a href="/about/cats.php">Cats</a>
hope it helps :)