CoachKip Posted April 7, 2007 Share Posted April 7, 2007 I hope that the subject title got your attention. I don't know how to put it under one subject but here is what I want to do: I want to have many pages all looking the same. Basically setting up a template for my site. What I want to do is have say index.php. Inside index.php I want to have calls that bring up a right_nav and left_nav, header, ect. I want it to look the same over the entire site. What I don't want to do is when I make a change to the right_nav (navigation section) I don't want to make it on every single page. I want to make the change in the nav file and have it in a seperate file, that I can call up on every single other page. Sorry if I am not to clear, I am not a programmer, I am just trying to make things easy on myself. Thanks Coach Kip Link to comment https://forums.phpfreaks.com/topic/46010-calling-sub-files-in-php/ Share on other sites More sharing options...
AndyB Posted April 7, 2007 Share Posted April 7, 2007 Use the include() function for each of the common elements. <?php include("right_nav.php"); Insert that statement exactly where you want the right_nav to appear. right_nav.php should contain only the html needed, i.e. no head/body/etc tags. Think of include like copy/paste by the server. Link to comment https://forums.phpfreaks.com/topic/46010-calling-sub-files-in-php/#findComment-223564 Share on other sites More sharing options...
CoachKip Posted April 7, 2007 Author Share Posted April 7, 2007 Could I make it as an inline statment using <?php include("right_nav.php") ?> and does the right_nav file have to be saved as a php or html file? Thanks for your quick reply on the previous post Link to comment https://forums.phpfreaks.com/topic/46010-calling-sub-files-in-php/#findComment-223569 Share on other sites More sharing options...
Demonic Posted April 7, 2007 Share Posted April 7, 2007 You can do that if the file is a .php and you can use html/php in a .php file Link to comment https://forums.phpfreaks.com/topic/46010-calling-sub-files-in-php/#findComment-223570 Share on other sites More sharing options...
CoachKip Posted April 7, 2007 Author Share Posted April 7, 2007 Wow you guys are good, problem solved in under a half an hour. Thanks a bunch Link to comment https://forums.phpfreaks.com/topic/46010-calling-sub-files-in-php/#findComment-223578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.