Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2002
    Location
    Toronto, Canada
    Posts
    286

    Headers & Footers

    I am currently using frames for my site www.nowdammit.com, It works ok, but I'd rather not use frames. What do you think about frames? Anyways, I would like to see some of your code for using headers & footers if possible. Is there a certain way of doing it that loads the fastest? My top frame does not require php, I am only using flash for the header.


    Thanks,
    Matt
    www.prolinker.com - free automatic linking to your website

  2. #2
    Join Date
    Sep 2002
    Location
    Dallas, TX
    Posts
    205
    I don't know about faster, but it's typically wise to use include_once() instead of include() so as to not accidentally include it twice...
    justin 'at' abrogo.com
    http://www.abrogo.com
    Shared Unix Hosting

  3. #3
    Join Date
    Sep 2002
    Location
    Phoenix area
    Posts
    1,121
    Learn survival/prepper information from a combat veteran at Graywolf Survival

  4. #4
    Join Date
    Aug 2000
    Location
    Tacoma, Washington
    Posts
    9,576
    Just use a server side include:

    PHP Code:
    <!--#include virtual="head.html" --> 
    for example for the head file. Rename your page to .shtml, or if you prefer to keep the .html extension, make a .htaccess file with this witten in it:

    PHP Code:
    AddType text/x-server-parsed-html .html 
    Greg Moore
    Former Webhost... now, just a guy.

  5. #5
    Generally frames = bad. For the site I'm building I am using a class which let's me use about 4 lines to create a page and all I need to do is plug in the content. This is probably more than you are looking for though. As has been said, a simple method is to just use includes:

    page.php
    PHP Code:
    <?php

        
    @ include 'header.htm';

        echo 
    'hello';

        @ include 
    'footer.htm';

    ?>
    header.htm

    Code:
    <p align="center">
    footer.htm

    Code:
    </p>
    Of course you don't want to take my <p> example literally!

    Sean
    SitePoint PHP Advisor - answering your PHP questions day and night!
    http://www.sitepoint.com

  6. #6
    I agree with the fact that frames are bad. Most search engines will tell you that you shouldn't use them.

    I recommend using css as much as you can to save on page size and then I use Macromedia MX templates for my pages. By creating template, I can edit one file and have it shove the changes to all of the other files that were based upon that one.

    There is also ssi include. This also works well and I have used this on a few sites. The only complaint with that is you either have configure your web server to parse things other than shtm or shtml for ssi, or name your files like that. It is also not real easy to preview on your local machine.

    jared

  7. #7
    Join Date
    Aug 2000
    Location
    Tacoma, Washington
    Posts
    9,576
    Originally posted by jnyost
    The only complaint with that is you either have configure your web server to parse things other than shtm or shtml for ssi, or name your files like that. It is also not real easy to preview on your local machine.
    The .htaccess file I mentioned above does a great job for parsing serverside includes. The performance hit is minimal so unless you're pushing hundreds of thousands of pages a day I wouldn't worry too much.

    The preview issue can be a bother though, if you're not using Dreamweaver (which uses a 'render engine' to show parsed pages in preview). You just need to use some lateral thinking

    Greg Moore
    Former Webhost... now, just a guy.

  8. #8
    Join Date
    Apr 2002
    Location
    Cornfield
    Posts
    131
    I find it's better to actually write your header and footer as a PHP function, so you can pass information to it that can change its appearance.
    Fire extinguisher extraordinare
    -------------------------------
    FastServers.Net NOC Admin

Posting Permissions

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