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 5 of 5
  1. #1
    New Coder
    Join Date
    Apr 2007
    Posts
    85
    Thanks
    1
    Thanked 0 Times in 0 Posts

    best Way To Use Include() For Managing the Site's Layout

    I am able to successfully develop the layout of my site on one page, using one html file and one css file. This particular page has a header, 3 columns (furthermost left is navigation, center is content, and far right is advertisement), and a footer.


    My question to you all, what is the best way to use PHP's include function to help keep my layout consistent?

    I was thinking I create my navigation bar, header, sidebar, content, and footer all in seperate .php files, and then simply include them on my index.php page. Is this the best way to do it? It this the way most people do it here?

    Thanks for any input/advice on the subject matter.

  • #2
    New Coder
    Join Date
    May 2007
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's an easy way to do it. It beats having to do each page in complete html, that's for sure.

  • #3
    New Coder
    Join Date
    Apr 2007
    Posts
    85
    Thanks
    1
    Thanked 0 Times in 0 Posts
    And one more question, if I use this method and put in let's say my header.html file <div id="header"></div> and refer to this in my index.php file as

    include("header.php");

    would that be correct or should I just do the header in the header.php file and leave the <div id="header"> in my index.php file.


    Basically what I am asking is should I leave the <div id="idnamehere"></div> in my index.php file, or should I put them all in the individual files?


    Which way would be easier to manager with css?

    Thank you.

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    It shouldn't matter too much, since whether the div is in the include or the individual pages, all you have to do is update the CSS to change the div.

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #5
    New Coder
    Join Date
    Apr 2007
    Posts
    85
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by whizard View Post
    It shouldn't matter too much, since whether the div is in the include or the individual pages, all you have to do is update the CSS to change the div.

    Dan

    Thanks, I went ahead and just put the <div id="idnamehere"></div> elements in my index.php file. Just seemed like a good thing to do, I guess it is just a preference then.


  •  

    Posting Permissions

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