dmccabe Posted March 28, 2008 Share Posted March 28, 2008 I am having an attempt at making a small intranet for my work. I have got myself confused about how to best display the content. I have a header.php with the main header image and menu, then I want it so when they click "Call Centre Dept" the main header stays, but the main content changes to that page, however each dept with have it's own index.php and it's own sub pages. Set out like this: /header.php /index.php /dbconnect.php /footer.php /callcentre/index.php /callcentre/page1.php Is the best way of keeping the header the same by using include('header.php') at the top of each new page? if so when I get to the /callcentre/index.php how do I call the header.php ? as if I use include('header.php') wont be now looking in /callcentre/ for the header.php instead of the root dir? Quote Link to comment https://forums.phpfreaks.com/topic/98310-confused-about-how-lay-it-out/ Share on other sites More sharing options...
MatthewJ Posted March 28, 2008 Share Posted March 28, 2008 Just call it with the full path from root include('path/to/file/header.php'); Quote Link to comment https://forums.phpfreaks.com/topic/98310-confused-about-how-lay-it-out/#findComment-503066 Share on other sites More sharing options...
wildteen88 Posted March 28, 2008 Share Posted March 28, 2008 Prepend $_SERVER['DOCUMENT_ROOT'] to your includes: include $_SERVER['DOCUMENT_ROOT'] . 'header.php'; Quote Link to comment https://forums.phpfreaks.com/topic/98310-confused-about-how-lay-it-out/#findComment-503068 Share on other sites More sharing options...
dmccabe Posted March 28, 2008 Author Share Posted March 28, 2008 Excellent thanks WildTeen, i knew I could just put the full path in but didnt want to do this as I know it is not good code. I think the document_root is what I was after Ok one more question at the beginning of my header I have: $title = "Intranet"; Then in the header: <title><? echo $title ?></title> Now say in the call centre page I want to put: $title = $title." - Call Centre" So that the title of the page becomes "Intranet - Call Centre" How can I do it if the title is set in the header ? that would mean that setting the variable in the call centre page would have no affect. Quote Link to comment https://forums.phpfreaks.com/topic/98310-confused-about-how-lay-it-out/#findComment-503085 Share on other sites More sharing options...
wildteen88 Posted March 28, 2008 Share Posted March 28, 2008 Unless header.php is included after you set the $title varable in the call center page then header.php will set the title to <title>Intranet - Call Centre</title> If header.php is set before then header.php will not retrieve the new updated title variable. PHP does not backtrack. Quote Link to comment https://forums.phpfreaks.com/topic/98310-confused-about-how-lay-it-out/#findComment-503088 Share on other sites More sharing options...
dmccabe Posted March 28, 2008 Author Share Posted March 28, 2008 bugger so how would you go about it? Quote Link to comment https://forums.phpfreaks.com/topic/98310-confused-about-how-lay-it-out/#findComment-503164 Share on other sites More sharing options...
discomatt Posted March 28, 2008 Share Posted March 28, 2008 Make your header file a function that you can call with a $title argument. http://php.net/functions Quote Link to comment https://forums.phpfreaks.com/topic/98310-confused-about-how-lay-it-out/#findComment-503167 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.