Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2011
    Location
    NYC
    Posts
    28
    Thanks
    5
    Thanked 0 Times in 0 Posts

    website structure

    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)
    Code:
    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
    Thanks, Igor

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    May 2011
    Location
    NYC
    Posts
    28
    Thanks
    5
    Thanked 0 Times in 0 Posts
    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!
    Last edited by mrdemin; 05-19-2011 at 06:45 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •