neilscott
Member
Posted 2 years ago #
Hello,
I am trying to combine dynamic menus (described so well in the codex) with another level of functionality that involves specifying a different php file for each top level page (which contain the subpages). Sounds complicated, well here's an example of how it should look: http://www.bipcorporate.com
What I don't seem to be able to work out is how to specify a specific php rule. This is what I've worked out so far:
<?php
if ($_SERVER[’SCRIPT_NAME’]='/about') {
include( TEMPLATEPATH . '/nav/about.php');
}
elseif ($_SERVER[’SCRIPT_NAME’]='/contact') {
include( TEMPLATEPATH . '/nav/contact.php');
}
else {
include( TEMPLATEPATH . '/nav/home.php');
}
?>
But it doesn't work.
Any ideas?
Thanks,
Neil
i'd try using $_SERVER["REQUEST_URI"] instead of $_SERVER['SCRIPT_NAME'].
But how does it not work exactly? Does it allways show home.php?
D
neilscott
Member
Posted 2 years ago #
Okay, I managed to sort it out, here is the solution:
<?php
if(stristr($_SERVER['REQUEST_URI'], '/about')){
include( TEMPLATEPATH . '/nav/about.php');
}elseif(stristr($_SERVER['REQUEST_URI'], '/brands')){
include( TEMPLATEPATH . '/nav/contact.php');
}elseif(stristr($_SERVER['REQUEST_URI'], '/investor')){
include( TEMPLATEPATH . '/nav/contact.php');
}elseif(stristr($_SERVER['REQUEST_URI'], '/careers')){
include( TEMPLATEPATH . '/nav/contact.php');
}elseif(stristr($_SERVER['REQUEST_URI'], '/media')){
include( TEMPLATEPATH . '/nav/contact.php');
}elseif(stristr($_SERVER['REQUEST_URI'], '/contact')){
include( TEMPLATEPATH . '/nav/contact.php');
}else{
include( TEMPLATEPATH . '/nav/home.php');
}
?>