xn1 Posted March 10, 2011 Share Posted March 10, 2011 Hello all, I'm looking for some advice on a problem. I have a very basic web page containing three section, the header, the content and the footer in that order. What I would like is the header and footer always on the page and only the content section change by means of links in a navigation bar. I've looked into iframes, php include, javascript and something called Ajax and must say I'm all a bit confused by it all. Which would be most advisable and how would I excecute it. My pages are as follows. Home page is. index.php Pages I would like to show in the content Div. about.php contact.php home.php If you need any more information, please let me know. Thank you in advance for your help. Quote Link to comment https://forums.phpfreaks.com/topic/230209-suggestions-on-how-to-achieve-my-goal/ Share on other sites More sharing options...
Sanjib Sinha Posted March 10, 2011 Share Posted March 10, 2011 In ASP.NET there is a concept called Masterpage where this can be solved easily. But in php, you have to break it up in this way: header.php, footer.php, left_section.php and right_section.php. In your left_section.php keep the navigation bar. Now in each page, include header.php, left_section.php and footer.php and in the right_section.php keep changing the content. I think this can best be tackled if you use a css style. There are many open source css style available in internet. A little bit goggling will come to your help. Best of luck. Quote Link to comment https://forums.phpfreaks.com/topic/230209-suggestions-on-how-to-achieve-my-goal/#findComment-1185555 Share on other sites More sharing options...
ManiacDan Posted March 10, 2011 Share Posted March 10, 2011 Sanjib's suggestion makes sense until he starts talking about CSS files. CSS has nothing to do with this. PHP Includes are the way to go for this. Make your header.php that prints out the titlebar, navigation, etc. Make your footer.php that prints out the footer, copyright, and any necessary footer code like tracking pixels or whatever. Then, every page on your site looks like this: <?php include("header.php"); //page contents include("footer.php"); If you require a database connection, make it in header.php. If you have functions that are required on every page, require them in header.php, etc. Header and footer can also be page-aware. The various $_SERVER variables like the request string and the page name are set by the user's REQUEST. If they visit your "aboutUs.php", then the request URI will be "aboutUs.php" even inside header.php, so you can highlight the page they're on in the navigation menu and everything. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/230209-suggestions-on-how-to-achieve-my-goal/#findComment-1185567 Share on other sites More sharing options...
xn1 Posted March 10, 2011 Author Share Posted March 10, 2011 Thank you for your replies. Would the solution you've described, load up new content in the content div, rather than refresh the whole page? Quote Link to comment https://forums.phpfreaks.com/topic/230209-suggestions-on-how-to-achieve-my-goal/#findComment-1185622 Share on other sites More sharing options...
isedeasy Posted March 10, 2011 Share Posted March 10, 2011 Thank you for your replies. Would the solution you've described, load up new content in the content div, rather than refresh the whole page? For that you will need to use AJAX. Quote Link to comment https://forums.phpfreaks.com/topic/230209-suggestions-on-how-to-achieve-my-goal/#findComment-1185630 Share on other sites More sharing options...
litebearer Posted March 10, 2011 Share Posted March 10, 2011 example of using ajax to do what you are wanting to do http://bcsales.org/ was modified from this http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm Quote Link to comment https://forums.phpfreaks.com/topic/230209-suggestions-on-how-to-achieve-my-goal/#findComment-1185633 Share on other sites More sharing options...
xn1 Posted March 10, 2011 Author Share Posted March 10, 2011 Ok thank you, I shall take a look at Ajax. Is Ajax supported by alot of browsers? Quote Link to comment https://forums.phpfreaks.com/topic/230209-suggestions-on-how-to-achieve-my-goal/#findComment-1185636 Share on other sites More sharing options...
ManiacDan Posted March 14, 2011 Share Posted March 14, 2011 AJAX is supported by all major browsers, especially if you download an ajax toolkit which is maintained by a separate party. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/230209-suggestions-on-how-to-achieve-my-goal/#findComment-1187438 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.