Done a lot of searching but I can't really find what I'm searching for I think, or I don't understand it...
I have a site with probably 50-60 links in 5-6 dirs.. its a gaming site..like a 'guide' for the game...
say i have the following directories:
and each dir has the links..
etc
/advanced/weaponfusing.php
I'd rather not have to type out all the links, so I was thinking of making all the files in their approp. directories... and using something like
$files = scandir(dir/');
foreach ($files as $value){
$file = explode('.',$value);
}
etc...would that iterate through the 6 directories with my pages in them and could it be put in a simple li loop or something (i'd clean it with css) so that I dont have to type all the links out a second time (after creating each file)? how would i go about doing something like this? is there a better way?
EDIT:EDIT:EDIT: So I just threw them all in an array like:
$pages = array('Home' => 'home.php',
'City Tour' => 'basics/tour.php',
'Daily Signin' => 'dailys/dailysignin.php',
'Game Mechanics' => 'misc/mechanics.php',
);
$currentPage = basename($_SERVER['REQUEST_URI']);
then i ran this:
<div id="mBox">
<h1>basics</h1>
<div class="mGroup">
<?php for each ($pages as $filename => $pageTitle) {
if($filename == $currentPage) { ?>
<ul>
<li class="current"><?php echo $pageTitle; ?></li>
<?php } else { ?>
<li><a href="<?php echo $filename; ?>"><?php echo $pageTitle; ?></a></li>
<?php } } ?>
</ul></div>
Now my nav reads:
- basics/tour.php
- dailys/dailysignin.php
- misc/mechanics.php
etc, as filenames...I'm on the right track, but I need the nav to display the first part of the array (the name), rather than the pathfilename.ext. Thats my first fix. Secondly, is there a way to take out the paths and use them between my h1 tags, so that the menu titles are the folder paths? I'm still trying to figure out the arrays within directories or however I'd say it, so it's a bit confusing to me. Any help is appreciated.