Announcement

Collapse
No announcement yet.

Guide to Server-Side Includes/Dynamic Content/Updating Pages At Once

Collapse
This is a sticky topic.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Thanks for this post, it was really helpful

    Comment


    • #17
      I use the PHP include method to put a menu at the top of each of my pages. When I first looked up how to do this on Google, I found this website that explained how to do it but also said that sometimes (the writer couldn't explain why) if the file being included was saved with the file extension .html it wouldn't work, but if it was renamed with .shtml, it would. Just thought I'd throw that out there.

      Apparently this was common enough that he recieved a lot of email about it, so if your page just isn't including, that just might be the reason.

      Comment


      • #18
        Originally posted by jansennerd10 View Post
        I use the PHP include method to put a menu at the top of each of my pages. When I first looked up how to do this on Google, I found this website that explained how to do it but also said that sometimes (the writer couldn't explain why) if the file being included was saved with the file extension .html it wouldn't work, but if it was renamed with .shtml, it would. Just thought I'd throw that out there.

        Apparently this was common enough that he recieved a lot of email about it, so if your page just isn't including, that just might be the reason.
        Are you sure they were talking about PHP includes? Do you have the source by any chance? The article was most likely talking about SSI.

        Comment


        • #19
          If you're using a php include, then the extension of the page that has the include must be .php.
          Cat-herder Extraordinaire

          Comment


          • #20
            http://www.boutell.com/newfaq/creating/include.html
            Apparently the .shtml thing applies to all server0side includes on some web hosts.

            Originally posted by Pegasus View Post
            If you're using a php include, then the extension of the page that has the include must be .php.
            That's what the site said too, but this line:

            Code:
            <? php include('top.shtml'); ?>
            works in all my .html files.

            Comment


            • #21
              That's really odd. Mind you, I label *all* my files as .php whether they have php code in them or not. Saves me having to do global changes later on if I decide to add a bit of programming to any one particular section.
              Cat-herder Extraordinaire

              Comment


              • #22
                Not a bad idea...

                Comment


                • #23
                  !!

                  Originally posted by Pappa View Post
                  That current PHP include will look for the file in that directory. You cannot do it from root, but you can with this;
                  <?php
                  $path = $_SERVER['DOCUMENT_ROOT'];
                  $path .= "/navmenu/menubar.php";
                  include_once($path);
                  ?>
                  I have been using the normal include to update all pages at once, but it does not like going into other folders. This works for that!

                  Now i use
                  <?php
                  $path = $_SERVER['DOCUMENT_ROOT'];
                  $path .= "/navmenu/navimenu.php";
                  include_once($path);
                  ?>
                  Instead of
                  <?php require_once('navimenu.php'); ?>
                  And it works great! Now its even easier to edit my website!
                  My screen name is HeyAwesomePeople.

                  Call me HAP for short.

                  Comment


                  • #24
                    Let's all not forget about requires in addition to includes. Here is a short and useful reference.

                    PHP include and require reference
                    Last edited by jardrake; 08-19-2012, 02:18 AM. Reason: heh Screwed up the link entirely

                    Comment


                    • #25
                      Most knowledge about PHP can be learned from the site www.php.net

                      Comment


                      • #26
                        I expect that I'll have an article some time in the coming months about using SSI with small CGI programs. For now, here's something else that you can do with the exec element. You can actually have SSI execute a command using the shell (/bin/sh, to be precise - or the DOS shell, if you're on Win32). The following, for example, will give you a directory listing.

                        Comment


                        • #27
                          Awesome Post

                          Comment


                          • #28
                            Thanks for this! Thumbs up! Keep it up sir!

                            Comment

                            Working...
                            X