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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jul 2003
    Posts
    262
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Loading part of a page?

    First let me say I don't currently know any php. I had read that it is possible to 'load' part of a page, such as a menu system, across any number of pages using a php script.

    Is this correct?

    Thanks.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, this is correct. And quite easy to do so. All you need is

    <?php
    include('path/to/my/file.html');
    ?>

    and the content of file.html gets inserted at exactly where you position that statement in your document.
    De gustibus non est disputandum.

  • #3
    Regular Coder
    Join Date
    Jul 2003
    Posts
    262
    Thanks
    1
    Thanked 0 Times in 0 Posts
    This sounds very cool. I'm about to save my menu as it's own html document, and try this out.

    Should I strip any of the tags from it? How about the DTD?

    Thanks again.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Only include the parts of the page you actually need. Think of it like pasting text at a specific location of the file. If the menu code is just some HTML elements, and should come right after opening body tag, you don't need to put header, DTD or similar information into your include file.

    Just try it out; it's really simple to understand the concept.
    De gustibus non est disputandum.

  • #5
    Regular Coder
    Join Date
    Jul 2003
    Posts
    262
    Thanks
    1
    Thanked 0 Times in 0 Posts
    for whatever reason it is not working. The rest of the page looks fine, then menu is missing. I tried the snip you posted:

    <?php
    include('menu.html');
    ?>

    I tried saving the page with the script as a .php file, I assume this is correct. It does not work either way, but when saved as .php and I view the source, the script itself does not appear.
    Last edited by mothra; 09-11-2003 at 04:26 AM.

  • #6
    Regular Coder
    Join Date
    Jul 2003
    Posts
    262
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Got It

    I had to save both the file to be included as well as the file with the script as .php files.

    Thanks!


  •  

    Posting Permissions

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