Looking for basic header/footer script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • YellowKard
    Senior Member
    • Dec 2000
    • 291

    Looking for basic header/footer script

    I'm trying to find a script / code to make a very simple script to get the job done. I'm recoding my site in php (majority of it will still just be html in a php file).

    I want to either get a script or know how to include files inside a php script so I can make a standard header and footer thought my site.

    Meaning.


    anything.php contains

    ----------
    header.bla (html or php)

    html

    footer.bla (html or php)
    ---------

    I'm pretty sure what I'm trying to do is simple but I'm making it sound complicated. Thanks a lot to anyone who'd be so kind as in to assist me

  • JimF
    Senior Member
    • May 2000
    • 1988

    #2
    Make your header file, name it header.php (or whatever you want). Make your footer file, name it footer.php - or whatever you want.

    In your page (index.php, for example), in the location you want your header, put this:

    Code:
    <?php  include("header.php"); ?>
    In the location you want to put your footer, put this:

    Code:
    <?php include("footer.php"); ?>
    Now, upload header.php, footer.php, and index.php to your server, and run index.php from your browser. If it was done correctly, you should see the contents of both your header and your footer files, along with whatever content goes on the page.

    HTH

    -jim

    Comment

    • YellowKard
      Senior Member
      • Dec 2000
      • 291

      #3
      Thanks a lot, thats exactly what I was needing to know, one question though, for the include do I need to use the system (absolute) or url (relitive) path?

      Comment

      • Godin
        Member
        • Oct 2000
        • 33

        #4
        relative path works fine

        Comment

        • YellowKard
          Senior Member
          • Dec 2000
          • 291

          #5
          great

          Comment

          • YellowKard
            Senior Member
            • Dec 2000
            • 291

            #6
            Considering the future how could I call my varibles (such as the path for header.php and footer.php) from an external file

            in other words say I got $header and $footer defined in another file, how could I define and call them so when I just use $header it prints the location of header.php in my output.

            Comment

            • chrispadfield
              Senior Member
              • Aug 2000
              • 5366

              #7
              you would have to

              Code:
              require ("config.php");
              where in config.php you have set

              $footer = "/includes/footer.php";
              $header = "/includes/header.php";

              and then just do

              include ($footer");

              i think that works, if wrong someone will point it out.
              Christopher Padfield
              Web Based Helpdesk
              DeskPRO v3.0.3 Released - Download Demo Now!

              Comment

              • YellowKard
                Senior Member
                • Dec 2000
                • 291

                #8
                thanks, you guys help me figure out something I couldn't do with 4 php tuturials

                Comment

                • Freddie Bingham
                  Former vBulletin Developer
                  • May 2000
                  • 14057
                  • 1.1.x

                  #9
                  this is what I use:

                  Code:
                  <?
                  chdir($DOCUMENT_ROOT . "/forums");
                  require("$DOCUMENT_ROOT/forums/global.php");
                  chdir($DOCUMENT_ROOT . "/include");
                  
                  if (!file_exists("$file.html")) $file = "404";
                  
                  $output="{htmldoctype}
                  <HTML>
                  <HEAD>
                  <TITLE>$bbtitle</title>
                  $headinclude
                  </head>
                  <body>
                  $header
                  <table border=\"0\" width=\"100%\" cellpadding=\"4\" cellspacing=\"1\">
                  <tr><td align=\"left\" width=\"100%\">
                  <img src=\"http://www.chins-n-quills.com/forums/images/closedfolder.gif\" border=0 width=14 height=11>
                  <b><FONT face=\"verdana,arial,helvetica\" size=\"2\"><a href=\"http://www.chins-n-quills.com/forums/index.php\">$bbtitle</A></font><
                  /b>
                  <img src=\"http://www.chins-n-quills.com/forums/images/closedfolder.gif\" border=0 width=14 height=11>
                  <b><FONT face=\"verdana,arial,helvetica\" size=\"2\">$file
                  </font></b>
                  </td></tr></table><br>";
                  
                  $output .=
                  implode('',file("http://www.chins-n-quills.com/include/$file.html"));
                  
                  $output .= "<br>$footer
                  </body>
                  </html>";
                  
                  print dovars($output);
                  ?>
                  That is called include.php and I call it like include.php?file=Privacy and it would load Privacy.html and place it inside my header/footer which maintains the look of my forum. The $footer and $header are supplied from global.php through the normal vbulletin routines. I use this so I can keep track of users on my site and display them on the forum index. When we get a chance to write who's online for vb2.1 than this can also be integrated into that to show where user's are outside your main forum.

                  Comment

                  • YellowKard
                    Senior Member
                    • Dec 2000
                    • 291

                    #10
                    Very cool, I can see how to edit it and all but I was just curious about how you learned php, I'm wanting to end up being able to create my own scripts and not just edit others.

                    Comment

                    • YellowKard
                      Senior Member
                      • Dec 2000
                      • 291

                      #11
                      Oh and one more thing, I'd like to comment how vB just resizes the reply that takes up more then the window width instead of the all the posts, unlike any other bulletin board I've seen.

                      Comment

                      • YellowKard
                        Senior Member
                        • Dec 2000
                        • 291

                        #12
                        I need some help, I know there are some obvious problems but I don't know how I would make this setup work.

                        This is my file tree

                        |
                        |- beta/
                        |------ index.php
                        |------ config/
                        |------------ config.php
                        |------------ header.php
                        |------------ footer.php
                        |

                        index.php contains:

                        Code:
                        <?php
                        chdir($DOCUMENT_ROOT . "/beta/config"); 
                        require("$DOCUMENT_ROOT/beta/config/config.php"); 
                        
                        // Page Settings
                        
                        ///////////////////
                        $title="This is a test";
                        $keywords="test,tester,testing";
                        $description="This is the description of a test";
                        ///////////////////
                        
                        include ("$header");
                        print "
                        
                        This is a <b>test</b>.
                        
                        ";
                        include ("$footer");
                        ?>
                        config.php contains:

                        <?php
                        chdir($DOCUMENT_ROOT . "/beta/config");
                        $header = "header.php";
                        $footer = "footer.php";
                        ?>
                        header.php contains:

                        Code:
                        <HTML>
                        <HEAD>
                        <TITLE><? $title ?></TITLE>
                        <META name="description" content="<? $description ?>">
                        <META name="keywords" content="<? $keywords ?>">
                        </HEAD>
                        <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">
                        and footer.php contains:

                        Code:
                        </BODY>
                        </HTML>

                        My server uses php 4 if that matters on how it should be coded.
                        Last edited by YellowKard; Fri 2 Feb '01, 12:44pm.

                        Comment

                        • YellowKard
                          Senior Member
                          • Dec 2000
                          • 291

                          #13
                          I swear I'll help others with the info I learn if someone helps me

                          Comment

                          • chrispadfield
                            Senior Member
                            • Aug 2000
                            • 5366

                            #14
                            first of you need to tell us what is going wrong.

                            I think the first problem is

                            ("/config/config.php");
                            change it to

                            Code:
                            ("config/config.php");
                            this is a path thing also i think this would work

                            Code:
                            ("/beta/config/config.php");
                            but you may even have to do:

                            chdir($DOCUMENT_ROOT . "/beta/config");
                            require("$DOCUMENT_ROOT/beta/config/config.php");

                            not sure, try them, tell me error messages you get for each and i will try and help.
                            Christopher Padfield
                            Web Based Helpdesk
                            DeskPRO v3.0.3 Released - Download Demo Now!

                            Comment

                            • chrispadfield
                              Senior Member
                              • Aug 2000
                              • 5366

                              #15
                              and it should be

                              include("$variable");

                              ie, both quotes, it was my mistake earlier one.
                              Christopher Padfield
                              Web Based Helpdesk
                              DeskPRO v3.0.3 Released - Download Demo Now!

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...