SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    External HTML File

    On my website, I have a ton of boxes with text in them. I want to be able to have that text in an external html file. Is this possible?

    Thanks in advance.

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    You'll need to use a server side language for this like PHP's include().

  3. #3
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply.

    I need PHP to have text from external html files? Is there any other way to do this without php? My host doesn't allow PHP...

    at the moment, I'm using external javascript files, like this: document.write("my text") but I need actual html files this time.

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    frames...iframes...those frame things...
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I had never used iframes before, so I didnt know how to use them, but I just googled them... These will work.

  6. #6
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Frames are an awful way to include HTML in your page. They have all sorts of issues including inability to re-size depending on content (without a crude Javascript fix) and they play havoc with search engines apparently. I've been using a free hosting service http://freehostia.com/ lately and haven't had any issues. They provide PHP/MySQL even in their free hosting package.

    PHP includes can be done like this:
    PHP Code:
    <? require("blabla.inc"); ?>
    It's easy peazy and much better than using frames.

    Ryan,

  7. #7
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Perhaps they may let you use SSI if not PHP. First it sounded like you wanted to use <object> though I assume you meant you wanted to include file data into the page.

  8. #8
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If all you want to do is to include text fragments, then SSI (server-side includes) should be the most appropriate tool. PHP would be overkill for that.

    Iframes should not even be considered, unless those texts you want to include are complete HTML documents. (And preferably not even then. )
    Birnam wood is come to Dunsinane

  9. #9
    SitePoint Wizard silver trophy linkin99's Avatar
    Join Date
    Sep 2005
    Location
    Wisconsin
    Posts
    1,456
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is what it sounds like he's looking for. To use SSI's you will need to have your host enable SSI's. Then, use the following code to call the specific files you want to include in your regular page.

    Code:
    <!--#include virtual="/includePath/fileToInclude.shtml" -->
    Just change the sample path to the actual file path (and name).

  10. #10
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought my suggestion above was a SSI!? I'm really confused now.

    What is the advantage of
    Code:
    <!--#include virtual="/includePath/fileToInclude.shtml" -->
    over using PHP?

    thanks,
    Ryan

  11. #11
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ryanhellyer View Post
    I thought my suggestion above was a SSI!? I'm really confused now.

    What is the advantage of
    Code:
    <!--#include virtual="/includePath/fileToInclude.shtml" -->
    over using PHP?

    thanks,
    Ryan
    To just include fragments of data into a page SSI which is at least to my knowledge is built into the server software is much faster. PHP is overkill for such a simple thing because the server (Apache) has to go out and call PHP with all the details and wait for a response back but SSI (again to my knowledge) is part of the server itself.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  12. #12
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ryanhellyer View Post
    What is the advantage of
    Code:
    <!--#include virtual="/includePath/fileToInclude.shtml" -->
    over using PHP?
    1. It's faster.
    2. It puts much less load on the server.
    3. It's simpler.
    4. Low-cost hosting is more likely to provide SSI than PHP.
    Birnam wood is come to Dunsinane

  13. #13
    SitePoint Zealot NinjaNoodles's Avatar
    Join Date
    Oct 2006
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    An advantage of PHP, however, is that you can do more than simply include files.

    Here's how I use it:

    Page 1's code:
    PHP Code:
    <?php
    $pageid 
    "home";
    include 
    "includes/header.inc";
    ?>
    Now, in header.inc, I can say:
    PHP Code:
    <title>Website Name | <?php
    $pageid 
    ucfirst($pageid);
    echo 
    $pageid;
    $pageid strtolower($pageid);
    ?></title>
    In nav.inc, I do this for the css "you are here" effect:
    PHP Code:
    <body id="<?php echo $pageid;?>">
    End result? Page 1 now has a title of "Website Name | Page 1," a header that reads, "page 1," and on the navigation menu, Page 1's link is highlighted.

    Makes editing pages a lot less tedious.


Bookmarks

Posting Permissions

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