Hi all,
I have a navigation system which this far has been unidimensional for which I've used a unidimensional array like so:
function mainpage( $page ) {
empty( $page ) ? $page = "default.php" : $page = $_GET[ "p" ];
$pagelist = array( "page1" => "page1.php",
"page2" => "page2.php",
"page3" => "page3.php" );
if( !empty( $page ) && in_array( $page, array_keys( $pagelist ) ) ) {
require( $pagelist[ $page ] );
} else {
print( "Page not found" );
}
}
and then used it on my index page by calling the mainpage function. Simple. This way I've had URLs such as www.server.com/?p=page1&id=123 and in doing a bit of htaccess translation, www.server.com/page1/123.
Now, I need to expand this a notch so that, for example, when I'm on page1 or page3, I don't see any subpages, but when accessing page2, I'd get a subnavigation and a bunch of links that would give me more pages from which I could then select containing links. Ie, I could have URLs such as www.server.com/?p=page2&sp=sub1&id=123. This would imply that page2 needs to be the top-level (without actually displaying the page2 content) and sub1 the actual page to be displayed.
I've tried to do this by cloning the aforementioned function and then using it selectively like so:
$content = $_GET[ "p" ];
$subcontent = $_GET[ "cat" ];
if( !isset( $content ) || !$content || $content == "" ) {
require( "default.php" );
} else {
if( isset( $content ) && $content == "something" ) {
mainpage( $content );
subpage( $subcontent );
} else {
mainpage( $content );
}
}
But this still gives me the page2 contents before the sub1 contents are displayed.
Can I do this somehow so that when page2 is selected, it's contents aren't displayed but sub1 instead? I would like to maintain the URL hierarchy so that I can maintain the rewritten www.server.com/page2/sub1/123 look.