Desnar Posted September 20, 2008 Share Posted September 20, 2008 Hi there, A few years ago I had this great php script that would make 'active' menulinks when you were on the designated page. section=news, menulink news would become active (bold and different colour). Recently I have started working on it again but I found out it doesn't work anymore the way it should. Only the home page is displayed, even though you click on news, contact or any other page. I use a different directory for every section, so index.php?section=news&page=main to link. Here's the code if the index page : <HTML> <?php if (!isset($section)) { $section='home'; } if (!isset($sub)) { $sub=''; } else { $sub .= '/'; } if (!isset($menu)) { $menu='menu'; } if (!isset($page)) { $page='main'; } // include header print("<head>"); include("home/header.php"); print("</head>"); // body print("<BODY MARGINWIDTH=\"0\" MARGINHEIGHT=\"0\" LEFTMARGIN=\"0\" TOPMARGIN=\"0\" bgcolor=#CCCCFF>"); // include top (logo & menu) include("home/top.php"); // include menu for $section and $sub if (file_exists("$section/$sub$menu.php")) { include("$section/$sub$menu.php"); } elseif (file_exists("$section/$menu.php")) { include("$section/menu.php"); } else { include("home/menu.php"); } // include page in sub in section if (file_exists("$section/$sub$page.php")) { include("$section/$sub$page.php"); } else { include("home/error404.php"); } // include bottom include("home/bottom.php"); ?> </HTML> In my top.php the menulinks are coded like this <a class="menu<?php if($section == 'home') print("over"); ?>" href="index.php?section=home" title="Klik op Visie als u onze visie wilt weten over webdesign"><b>home</b></a> Can anyone help, I'm totally stuck and I can't remember how I solved this before. Thanks in advance, Quote Link to comment https://forums.phpfreaks.com/topic/125062-solved-creating-a-menu-with-sections/ Share on other sites More sharing options...
Minase Posted September 20, 2008 Share Posted September 20, 2008 im not sure but you can try to replace if (!isset($section)) { with $section = $_GET['section']; if (!isset($section)) { should work like a charm Quote Link to comment https://forums.phpfreaks.com/topic/125062-solved-creating-a-menu-with-sections/#findComment-646309 Share on other sites More sharing options...
Desnar Posted September 20, 2008 Author Share Posted September 20, 2008 Great! Thanks Works great, all those hours of looking for such an easy solution. Many thanks! Quote Link to comment https://forums.phpfreaks.com/topic/125062-solved-creating-a-menu-with-sections/#findComment-646312 Share on other sites More sharing options...
Minase Posted September 20, 2008 Share Posted September 20, 2008 dont forget to add topic solved in this way we will keep the forum clean Quote Link to comment https://forums.phpfreaks.com/topic/125062-solved-creating-a-menu-with-sections/#findComment-646315 Share on other sites More sharing options...
Desnar Posted September 20, 2008 Author Share Posted September 20, 2008 dont forget to add topic solved in this way we will keep the forum clean Roger that, just noticed the topic about it Quote Link to comment https://forums.phpfreaks.com/topic/125062-solved-creating-a-menu-with-sections/#findComment-646323 Share on other sites More sharing options...
Desnar Posted September 20, 2008 Author Share Posted September 20, 2008 Not solved, just ran into a problem with the sub section. For example: index.php?section=news&page=archive That page won't be displayed and I'm stuck on the main page of that section. Tried to ajust to code as I did with section bit but keep getting an error. Here's what I changed it to <HTML> <?php $section = $_GET['section']; if (!isset($section)) { $section='home'; } if (!isset($sub)) { $sub=''; } else { $sub .= '/'; } if (!isset($menu)) { $menu='menu'; } if (!isset($page)) { $page='main'; } Any suggestion? Quote Link to comment https://forums.phpfreaks.com/topic/125062-solved-creating-a-menu-with-sections/#findComment-646327 Share on other sites More sharing options...
Desnar Posted September 20, 2008 Author Share Posted September 20, 2008 This got my a bit further but still no subpages displayed $section = $_GET['section']; if (!isset($section)) { $section='home'; } $sub = $_GET['sub']; if (!isset($sub)) { $sub=''; } else { $sub .= '/'; } if (!isset($menu)) { $menu='menu'; } if (!isset($page)) { $page='main'; } Quote Link to comment https://forums.phpfreaks.com/topic/125062-solved-creating-a-menu-with-sections/#findComment-646337 Share on other sites More sharing options...
Desnar Posted September 20, 2008 Author Share Posted September 20, 2008 And solved by ajusting both $sub, $menu & $page. Working code <?php $section = $_GET['section']; if (!isset($section)) { $section='home'; } $sub = $_GET['sub']; if (!isset($sub)) { $sub=''; } else { $sub .= '/'; } $menu = $_GET['menu']; if (!isset($menu)) { $menu='menu'; } $page = $_GET['page']; if (!isset($page)) { $page='main'; } Quote Link to comment https://forums.phpfreaks.com/topic/125062-solved-creating-a-menu-with-sections/#findComment-646340 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.