abi.the.unicorn Posted October 29, 2008 Share Posted October 29, 2008 I haven't maintained a website for a long time and I have recently started on a new website project and have a problem. When I used to run a lot of websites, I used PHP to help me easily make changes to the layout and have the changes take effect on every single page, even though I only edited it on one 'master' page. If i remember correctly, I had one page, usually called main.php which contained the code for my site's layout (in html/css). I then would make all my other pages, and they would simply be plain text with some php code in them which added the layout in main.php to the page I created. So, I could easily add a new link to the navigation in main.php and it would appear on all of the pages. I'm trying to start with my new website project but I can't possibly just make all the pages .html and manually make changes to every single one. I would appreciate it if anyone could give me the code I need to use and tell me how to use it. I know absolutely no php but I am experienced in HTML/CSS. If no one can do that, I would still appreciate just the name of what I am trying to do so I can google for some kind of tutorial. I have searched a lot of forums and google but can't find my answer because I don't really know what it is I'm looking for. Link to comment https://forums.phpfreaks.com/topic/130557-using-php-to-repeat-and-easily-edit-htmlcss-layout-on-all-pages-at-once/ Share on other sites More sharing options...
asmith Posted October 29, 2008 Share Posted October 29, 2008 what code you are looking for ? you can put : include('main.php'); in all of your pages, and you have it in all your pages. Link to comment https://forums.phpfreaks.com/topic/130557-using-php-to-repeat-and-easily-edit-htmlcss-layout-on-all-pages-at-once/#findComment-677344 Share on other sites More sharing options...
abi.the.unicorn Posted October 29, 2008 Author Share Posted October 29, 2008 Well, I'm looking for any code I need to try and do what I attempted to explain. Is that all the code I need? When I used it before I listed all the pages the layout was used in in the code. Something like: include('main.php' contact.php help.php morepage.php anotherpage.php allthepages.php); It wasn't exactly like that but it was something similar. And the URLs to the pages changed. It was like /site.com/pages/contact.php?go=contact or something. Take my examples of code with a pinch of salt, theyre just guesses and not exactly the code I used! :-\ Link to comment https://forums.phpfreaks.com/topic/130557-using-php-to-repeat-and-easily-edit-htmlcss-layout-on-all-pages-at-once/#findComment-677590 Share on other sites More sharing options...
JADASDesigner Posted October 29, 2008 Share Posted October 29, 2008 Using include is almost like cutting and pasting code. Lets say you have a site that has 500 pages, and you want to change the footer on all of them. Instead of having the footer on all of the pages, create a file called footer.php that has all of your html/php in it that is supposed to be in the footer. Then, on the pages, instead of all of the footer code, you just need <?php include ('path/to/footer.php'); ?> and you will only need to edit that one document, instead of all 500. to do it with CSS, all you need to do is: <link href="path/to/Stylesheet.css" rel="stylesheet" type="text/css" /> Happy Trails. Link to comment https://forums.phpfreaks.com/topic/130557-using-php-to-repeat-and-easily-edit-htmlcss-layout-on-all-pages-at-once/#findComment-677662 Share on other sites More sharing options...
abi.the.unicorn Posted October 29, 2008 Author Share Posted October 29, 2008 Thankyou for your help! I have just finished coding a new layout because I got annoyed with the first one I made. Haha. Anyway, I will try and get around to trying these new codes in the next few hours. I'll post here if I encounter any problems! Link to comment https://forums.phpfreaks.com/topic/130557-using-php-to-repeat-and-easily-edit-htmlcss-layout-on-all-pages-at-once/#findComment-677717 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.