Adding a navigation bar to 'wrap' two indexes?

Hi and thanks for your patience. I don’t even know if I’m asking the right question. I run forums for a gaming group using phpbb3. Recently I was asked to add stats to our site and found a nice solution called psychostats. Each has their own subdirectory and index.php. What I would like to do is make a persistent navigation bar that would easily swap back and forth between the two indexes. Currently I’ve managed this using frames but this leads to the problem of losing the navigation if a link is opened in another tab or window. I tried searching for solutions but again I’m not sure how to phrase my request so haven’t found anything specifically helpful. Thanks for any help!

Here’s the site frameset: http://www.underworldgaming2.com
phpbb dir: http://www.underworldgaming2.com/Forums
psychostats dir: http://www.underworldgaming2.com/psychostats

put your navigation in a php file then using includes to bring the file into the various pages that need it.

Dave, hi and thanksfor your response!

I will give this a try, I’m still pretty new with PHP so I will look up some tutorials. Do you think I will ned to add it to each individual theme or should the index filesbe enough?

including files is really simple here’s a tutorial I wrote on it: http://www.developerstoolkit.co.uk/tutorials/php/including-files/

If the themes make use of the indexes then that’s probably the only place you need to put it.

Okay while trying to get this sorted out in my headI think I ran into a snag the forums and stats index.php are in their own subdirectory and the frameset is one level up. By default the top level of the domain shows the navigation and the forums as content. By adding the includes I feel like I would have to redirect from the top level to the subdirectory “…/Forums/index.php” Would it work to create an index with navigation at root and use an “if/else” script to include either the stats or Forums directory as content?

yes exactly you can include as many files as you want, or have an absolute path in the navigation rather then relative paths.

The more I read the more I confuse myself and perhaps over complicate the issue. Currently I have than index.htm. In that file I have simple html with a table as a navigation menu:

<table width="100%" border="0" cellpadding="0">
  <tr>
    <td>Welcome to the Underworld</td>
    <td width="100" align="right"><a href="../stats/">Stats</a></td>
    <td width="100" align="right"><a href="../Forums/">Forums</a></td>
  </tr>
</table>

My thoughts are that after the table I need to add something like:

<?php
include("../Forums/index.php")
?>

I feel like, in order to use an if/else based on the link I need to somehow define those links as variables. Would I add those variables above the body tag before the menu? I’m still figuring out the if/else part. Thanks for your patience!

what are the if/else for?
If they control links paths then it would be a lot easier to have the full path:

[code]

Welcome to the Underworld Stats Forums
[/code]

Okay I think I am understanding a bit better I found a tutorial using ajax what do you think of this?
My menu bar:

<table width="100%" border="0" cellpadding="0">
  <tr>
    <td>Welcome to the Underworld</td>
    <td width="100" align="right"><a href="index.php?page=stats">Stats</a></td>
    <td width="100" align="right"><a href="index.php?page=forums">Forums</a></td>
  </tr>
</table>

My root index:

<?
include("header.php")

//sets the default page to home
$page_content = "http://www.underworldgaming2.com/Forums/index.php";

//if loading a different page, which one?
if(isset($_GET['page'])){
switch($_GET['page']){

case "stats":
$page_content = "http://www.underworldgaming2.com/stats/index.php";
break;

case "forums":
$page_content = "http://www.underworldgaming2.com/Forums/index.php";
break;

}
}

//load the contents into my site
include($page_content);

?>

that looks like a great way of doing it, there’s no ajax in there thought is that something you plan on adding at a later stage?

no idea! lol the tutorial mentioned the script used ajax so that’s the only reason I mentioned it. Okay! I will give this a shot!

UPDATE:
well I’ve botched something. Received error: Parse error: syntax error, unexpected T_VARIABLE in /path/index.php on line 5

so something wrong with this:

$page_content = "http://www.underworldgaming2.com/Forums/index.php";

no it’s the previous line it’s missing a ; on the end

[php]include(“header.php”);[/php]

When you see the error unexpected T_VARIABLE check the line before the one it mentions.

Aha! Thank you for the tip. Okay no error this time but no content either. Only the nav shows up. Here’s the updated code:

nav.php

<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Geneva, sans-serif;
	color: #FFF;
	font-size: 12px;
}
body {
	background-color: #000;
}
a:link {
	color: #FFF;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #FFF;
}
a:hover {
	text-decoration: underline;
	color: #F60;
}
a:active {
	text-decoration: none;
	color: #F60;
}
-->
</style>
<table width="100%" border="0" cellpadding="0">
  <tr>
    <td>Welcome to the Underworld</td>
    <td width="100" align="right"><a href="index.php?page=stats">Stats</a></td>
    <td width="100" align="right"><a href="index.php?page=forums">Forums</a></td>
  </tr>
</table>

index.php

<?
include("nav.php");

//sets the default page to home
$page_content = "http://www.underworldgaming2.com/Forums/index.php";

//if loading a different page, which one?
if(isset($_GET['page'])){
switch($_GET['page']){

case "stats":
$page_content = "http://www.underworldgaming2.com/stats/index.php";
break;

case "forums":
$page_content = "http://www.underworldgaming2.com/Forums/index.php";
break;

}
}

//load the contents into my site
include($page_content);

?>

it could be the files are not being included since they contain the full path including http:// on some server including files as set to fail on what’s called a http wrapper in those cases includes cannot contain http this may be the case.

I tried absolute pathing too e.g. “root/www/Forums/index.php” but no dice. Time for some more reading! :smiley: Thanks for your help and Patience Dave. It’s really appreciated!

you could make sure there is a path been sent in

[php]//load the contents into my site
include($page_content);[/php]

by printing out the contents of $page_content

[php]echo “page content: $page_content”;

//load the contents into my site
include($page_content);
[/php]

Unfortunately that only prints out the path, it doesn’t open the index.php :frowning:

Sponsor our Newsletter | Privacy Policy | Terms of Service