What can I do to better structure my File Directory?

bubba

New Member
I am working on a dynamic blog/portfolio:Ref Link: http://www.andrewryan.me/I have been working on my personal website for more than a month now. I keep modifying things because I feel like I am setting up this entire thing wrong. I know I am in some way or another and I am finally asking for help. I have been working on a dynamic site structure and I would like to know a few things:[*]Best practices' for dynamic content.
  • I have the frame of the site in the root folder. This includes the index and styles.
    (along with the scripts folder, images folder and other misc file types..)
  • The newest blog entries are pulled up on the index page. If they wanted to see all my professional posts/topics they'd just go to any given sub section.
    (e.g: index.php?p=professional)
  • From there; If a user wanted to view a blog post in it's entirety, they'd just click on the post and then that's further-dynamically pulled up.
    (e.g: index.php?p=professional/thispost (idfk))
[*]How to create dynamic content inside of dynamic content.
  • Pages and SubPages then continue on down the chain within the personal folder. (e.g: index.php > index.php?p=personal)
[*]How to make updatable content that will file in once a page is uploaded to it's respective folder.
  • Should I be looking into using a database or XML for this? And if so, can anyone point me to any good tutorials on making this type of website? No need to explain too much on this.
Here's my file structure:\[code\]root/ > images/ ||--> x.png > pages/ ||--> personal.php ||--> professional.php ||--> contact.php ||--> 404.php ||--> contact.php > personal/ |||--> personalposts.php > professional |||--> professionalposts.php > gallery/ |||--> galleryposts.php > scripts ||--> scripts.php/js/etc |--> .htaccess |--> index.php |--> style.css |--> robots.txt |--> humans.txt\[/code\]...and the code for dynamic pages:\[code\]<?php $pages_dir = 'pages'; //Scans the pages directory if (!empty($_GET['p'])) { //If not empty it will get the file $pages = scandir ($pages_dir, 0); //Sets up files as array unset ($pages[0], $pages[1]); //Unsets the first two. These are just dots. $p = $_GET['p']; if (in_array($p.'.php',$pages)) { include ($pages_dir.'/'.$p.'.php'); } else { include($pages_dir.'/404.php'); //DENIED! } } else { include($pages_dir.'/blog.php'); //if it's the index page }?> \[/code\]I more or less want to know if I got the structure down right or if there's a better way to do this. I'd like to be able to make this website once and just auto-update it content-wise when needed.
 
Back
Top