mrdemin
05-19-2011, 07: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)
if(isset($_GET['about']))
{
include 'includes/header.php';
include 'includes/about.php';
include 'includes/footer.php';
}
if(isset($_GET['profile']))
{
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
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)
if(isset($_GET['about']))
{
include 'includes/header.php';
include 'includes/about.php';
include 'includes/footer.php';
}
if(isset($_GET['profile']))
{
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