shortysbest Posted April 29, 2010 Share Posted April 29, 2010 I'm trying to figure out the best way to code a fully dynamic website. I'm not entirely sure what the best approach to this is. What i have been doing is using subpages so i have one page that i make all my dynamic changes to ie. Navigation bar, header info, then the content area is pulled in with some code from pages such as, content.php. the url for this looks like. www.mysitename.com/index.php?page=content index.php being the template page, and content being content.php. im not sure what the best approach for a professional dynamically built website would be. Link to comment https://forums.phpfreaks.com/topic/200189-most-professional-way-to-create-php-dynamic-website/ Share on other sites More sharing options...
jdavidbakr Posted April 29, 2010 Share Posted April 29, 2010 Lots of ways to do it, I don't know that any one is the best. If you want to use query strings, you could do a switch() statement: switch($_GET['page']) { case 'home': include "home.html"; break; default: include "index.html"; break; } Or you could have each .php page contain the same set of includes: <? include "header.html"; // content here include "footer.html"; ?> or any number of other methods. You could go so far as to build classes that handle each page element and have a master class that draws the page. It's really up to you and how you plan to maintain your site's content. Link to comment https://forums.phpfreaks.com/topic/200189-most-professional-way-to-create-php-dynamic-website/#findComment-1050625 Share on other sites More sharing options...
andrewgauger Posted April 29, 2010 Share Posted April 29, 2010 I like dynamic includes. Do: if ($_GET['page'] == "content") { include("content.php"); } DO NOT: include($_GET['page'].".php"); Link to comment https://forums.phpfreaks.com/topic/200189-most-professional-way-to-create-php-dynamic-website/#findComment-1050627 Share on other sites More sharing options...
Mchl Posted April 29, 2010 Share Posted April 29, 2010 The 'most professional' method these days seems to be implementation of a Model-View-Controller pattern. Link to comment https://forums.phpfreaks.com/topic/200189-most-professional-way-to-create-php-dynamic-website/#findComment-1050633 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.