UrbanDweller Posted October 5, 2011 Share Posted October 5, 2011 Hey Im always trying to remove code and cut corners to reduce work in the long run, soIim wondering how I could link my menu bar from say a template to ALL my php pages for my site so I don't have to write/change links on every page when I need to. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/248486-linking-single-menu-bar-to-multiple-pages/ Share on other sites More sharing options...
thomasw_lrd Posted October 5, 2011 Share Posted October 5, 2011 You need to look into using includes. I use a file called header.inc. This contains my menu. All my other pages have include header.inc Quote Link to comment https://forums.phpfreaks.com/topic/248486-linking-single-menu-bar-to-multiple-pages/#findComment-1276063 Share on other sites More sharing options...
UrbanDweller Posted October 5, 2011 Author Share Posted October 5, 2011 Are you able to give me an example? do you carry the css in the header too for the menu? Quote Link to comment https://forums.phpfreaks.com/topic/248486-linking-single-menu-bar-to-multiple-pages/#findComment-1276067 Share on other sites More sharing options...
UrbanDweller Posted October 5, 2011 Author Share Posted October 5, 2011 Ok i found info on include thanks Put this on the menubar.html <!--#include virtual="path to file/include-file.html" --> add this code to every page you want menu bar on <?php require($DOCUMENT_ROOT . "path to file/include-file.html"); ?> Just wont let me work from folder to folder, any method? Quote Link to comment https://forums.phpfreaks.com/topic/248486-linking-single-menu-bar-to-multiple-pages/#findComment-1276069 Share on other sites More sharing options...
BizLab Posted October 5, 2011 Share Posted October 5, 2011 Try using links for the include (and the navigation) based on the document root require_once('/header.php'); instead of require_once('../../header.php'); // and so on that should work just fine Quote Link to comment https://forums.phpfreaks.com/topic/248486-linking-single-menu-bar-to-multiple-pages/#findComment-1276081 Share on other sites More sharing options...
UrbanDweller Posted October 5, 2011 Author Share Posted October 5, 2011 Cool all working apart from i think the css cause my page is a full page down after a blank page lol Quote Link to comment https://forums.phpfreaks.com/topic/248486-linking-single-menu-bar-to-multiple-pages/#findComment-1276087 Share on other sites More sharing options...
UrbanDweller Posted October 5, 2011 Author Share Posted October 5, 2011 Um my jade script for my menu doesnt run through this Quote Link to comment https://forums.phpfreaks.com/topic/248486-linking-single-menu-bar-to-multiple-pages/#findComment-1276103 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.