NathanLedet Posted July 18, 2008 Share Posted July 18, 2008 I would like to re-structure a project management site I've been working on. The way I currently have it is very difficult to follow and not very upgradable. For instance, each action that I take, a new page has to be created. Example: If i'm on AddressBook.php and I want to add someone to my address book, I have addressbook_add.php or if i want to delete someone, i have addressbook_delete.php. Each file querys the database and I have a lot of junk everywhere...it's complicated to follow. What I would rather do is use functions in a manner that I've seen used before, where it's something like admin.php?pg=main and for my addressbook I would use somthing like admin.php?pg=addaddress and deleting would be like admin.php?pg=deleteaddress&id=23 where 23 is the ID of the person being removed from the address book. So instead of having numerous pages, I have only admin.php which calls up an external functions file. Inside that file contains all of my functions which do whatever they need. Where can I start? Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted July 19, 2008 Share Posted July 19, 2008 Well you need admin.php. Then I would suggest putting the other files in another directory called "pages" or "includes" or something. Then in your admin.php, where you want the content to appear you would have this: if(!isset($_GET['pg'])){ $pg = "defaultpage"; }else{ $pg = $_GET['page']; } if(file_exists("includes/".$pg.".php")){ include("includes/".$pg.".php"); }else{ //They tried to access a page that does not exist //Include your 404 error page } Good luck! Quote Link to comment Share on other sites More sharing options...
Lodius2000 Posted July 19, 2008 Share Posted July 19, 2008 i would try looking at wordpress's code, their create, and edit pages are the same and pretty sweet when you look at the code, its kinda over my head in general and they use all their own functions, but if you look at it for 15 minutes or so you might get some ideas Quote Link to comment Share on other sites More sharing options...
vikramjeet.singla Posted July 19, 2008 Share Posted July 19, 2008 if you want to restructure the site then i would suggest you to arrange the code in any framework suitable as per requirements. However it would take some time to learn but your site will be organized and extensible for future..... Quote Link to comment 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.