View Full Version : website structure

05-19-2011, 08:59 AM
Me again, having some difficulties structuring my site now!

I'm reading a book, which suggests using a controller... Basically navigate to pages when some if conditions are met... for example if $_GET is set to 'add', it will navigate to a page where you can add a joke and the url will be ./index.php?add
if a user just navigate to index.php they will get a different page.

I'm not sure if to use a controller for ALL of my pages, or use more than one controller in different directories (articles/ , profile/ , gallery/ ).

I've also read about making a directory for every page to make the URLs more user friendly (then again you can re-write them with htaccess).

The way I have it set up at this moment, is I have an index.php, which includes the header, page, footer based on the $_GET value.

Basically I have my header as an include, my footer, and every page content area is a seperate include.

It looks like this (in case my explanation is terrible)

include 'includes/header.php';
include 'includes/about.php';
include 'includes/footer.php';

include 'includes/header.php';
include 'includes/profile.php';
include 'includes/footer.php';

I don't know if this is bad practice but it seems to work, of course I'm open to change. I've also tried adding include header/footer on every seperate page but then I read thats not the best practice either.

Perhaps I'm just lost with what I need and the scope of my project is just too much, although I'm taking it it one step at a time, just this step is bothering me.

What the "completed" project will be is:
A user login, profile page, image gallery, user specific gallery, article page, rating system, as well as some plain "about" page maybe, a contact page... Some areas will be restricted to guests, some content will be different for guests (the navigation for example).

Can anyone help me with the structure so I can spend more time coding and less time trying to figure this structure thing out! I'll paypay someone 20 bucks for a good answer lol :o
Thanks, Igor

05-19-2011, 11:16 AM
Take a look at http://www.codingforums.com/showthread.php?t=129123

05-19-2011, 07:34 PM
Sooo even though that whole thread was about setting different header content, I think I've learned that you meant to imply that instead of having an "if" for every page that I have, I can rather use include '$somepage' ; once ?
Isn't that basically the same thing I have just a shorter version?

If a certain page needs a DB connection, in the set up I have now, I can just add it to the ifs in the index page, say I go the simplified way, I'd have to add the DB/auth stuff to the pages one by one...
Or I would specify it in the "models"

I'm not quiet getting something...

Should I have a seperate dir for pages that required their own controller (handler?), say make a ..articles/index.php. In there would be a page to submit stuff, and display stuff. Say a person came to .com/articles , it would load the index page which in turn checks for a $_GET, if none is found it will load the displaystuff page. If a ?submit is passed, it will load sumbmitstuff page.. ?
Then something similar with the gallery...

I guess I just cant find a "right" way to do this!