what you think is this method is good?

Discussion in 'PHP' started by astrohope, Mar 30, 2010.

  1. #1
    I make 1 website using this method , the website have 3 column , Left_body.php, right_body.php, body_center.php and header.php and footer.php i make them individual , then i make 1 file name index.php, and use this method to add all in index
    <?php include ("body_center.php");?>

    in body_center.php i call all the other html page links with this method

    else if ($_GET['id'] == "articles"){
    include ("centerbody/articles.html");
    }
    else if ($_GET['id'] == "sharfa_shames"){
    include ("centerbody/articals/sharfa_shames.html");}

    i have so many page and links and i dont want to make mess i use this method because when i add any new page i just make that html page in centerbody and include and make link in just body_center.php file ,

    what you think is this method is good?
     
    astrohope, Mar 30, 2010 IP
  2. stOK

    stOK Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    If you are able to organize your folders and validate user input you can simplify and shorten overall code
    wordpress is using similar technique
     
    stOK, Mar 30, 2010 IP
  3. Cloud Computing Forum

    Cloud Computing Forum Guest

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Nothing wrong with that method it's quite common, if it makes it easier to organize things then go for it!
     
    Cloud Computing Forum, Mar 30, 2010 IP
  4. iandracaster

    iandracaster Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    yep, nothing wrong with that code, but if you have, say it one hundred pages, then the code body_center.php will be long enough and it will be increase at the same time when you add more pages. it's not good enough actually from the development point of view. you should try to organize the article in category and then build some static class that handle that category folder and the files in each category folder, maybe by fetch all the files names under the category into static array or something like that and then validate and associated it with the given query string in url. in that way, you will just have to put the file in the folder and no need to change the code every time you add a page in your site...
     
    iandracaster, Apr 1, 2010 IP
  5. nimonogi

    nimonogi Active Member

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    80
    #5
    I agree with iandracaster. Also this way i believe will load pages faster instead of using lots of "else if" statements.
     
    nimonogi, Apr 1, 2010 IP