SitePoint Sponsor |
|
User Tag List
Results 1 to 13 of 13
Thread: External HTML File
-
Dec 5, 2006, 16:21 #1
- 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.
-
Dec 5, 2006, 16:30 #2
- 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().
-
Dec 5, 2006, 16:39 #3
- 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.
-
Dec 5, 2006, 16:53 #4
frames...iframes...those frame things...
-
Dec 5, 2006, 17:03 #5
- 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.
-
Dec 5, 2006, 21:19 #6
- 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"); ?>
Ryan,
-
Dec 6, 2006, 09:16 #7
- 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.
-
Dec 6, 2006, 09:36 #8
- 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
-
Dec 6, 2006, 12:03 #9
- 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" -->
-
Dec 6, 2006, 14:44 #10
- 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" -->
thanks,
Ryan
-
Dec 6, 2006, 15:50 #11
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.
-
Dec 7, 2006, 00:13 #12
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Dec 7, 2006, 03:24 #13
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";
?>PHP Code:<title>Website Name | <?php
$pageid = ucfirst($pageid);
echo $pageid;
$pageid = strtolower($pageid);
?></title>PHP Code:<body id="<?php echo $pageid;?>">
Makes editing pages a lot less tedious.
Bookmarks