hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Web Design and Content : Importing an External Document
Reply

Web Design and Content Subjects include, HTML, graphics, editors, CSS, Flash, graphics creation, placing of ads, ad serv companies, copyright, content and nearly anything else design related. Also talk about businesses that provide design services. If you link to your site, you must post in Web Site Reviews.
Forum Jump

Importing an External Document

Reply Post New Thread In Web Design and Content Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 01-17-2009, 04:30 PM
sithpigeon
Guest
 
Posts: n/a
Hello,
I'm working on a website for a guy and I was trying to think of a way to make it easier for him to add content to it. My thought was to make two html documents. One with all the layout information and colors and another that holds the text that gets displayed in the main body. That way he only has to edit the one with the text and never has to mess with the coding.
After looking around I haven't found any way to do this easily, although I know you can import external CSS documents and thought it would be a similar process.
If anyone knows how you can do this I would greatly appreciate the knowledge.

Reply With Quote


Sponsored Links
  #2  
Old 01-17-2009, 09:25 PM
bear bear is online now
Community Leader
 
Join Date: Oct 2002
Location: cognito
Posts: 17,321
Simplest way would be to include the external doc by using a PHP page instead of HTML as the one to display it in. Make your page as usual, but where the content is to be included:
<?php include('/path/to/included/file.ext'); ?>
There are probably a dozen other ways, but that's the simplest, I feel.

Reply With Quote
  #3  
Old 01-17-2009, 09:31 PM
sithpigeon
Guest
 
Posts: n/a
Thanks,
I tried it but the text didn't show up when I loaded the main page. Could you elaborate more for me? Does the external doc have to be php or the one calling it?

Reply With Quote
Sponsored Links
  #4  
Old 01-17-2009, 09:51 PM
bear bear is online now
Community Leader
 
Join Date: Oct 2002
Location: cognito
Posts: 17,321
In order for the page to be included, the calling page needs to be parsed by the PHP engine. By default, naming it with ".php" at the end is how it's done.
You could also tell the server to parse HTML pages in the same way, but it's not recommended, mainly because if something goes wrong...it will happily expose all your PHP code, and it adds extra overhead to rendering all HTML pages.

Reply With Quote
  #5  
Old 01-18-2009, 11:58 AM
peter_anderson peter_anderson is offline
Web Hosting Evangelist
 
Join Date: Jun 2008
Location: Glasgow, United Kingdom
Posts: 480
There is also SSI.
You will need to change the extension to .shtml instead of .html.
<!--#include virtual="header.html"-->
header.html would be where your code is.

Reply With Quote
  #6  
Old 01-18-2009, 09:48 PM
sithpigeon
Guest
 
Posts: n/a
Uhm, I think I'm a little confused. I have a regular html document and I want it's contents to show up on another page. I've tried these and all I get is a blank page.

Reply With Quote
  #7  
Old 01-18-2009, 09:58 PM
bear bear is online now
Community Leader
 
Join Date: Oct 2002
Location: cognito
Posts: 17,321
Do you have PHP installed on the server? The method I gave requires it. Make one page that will serve as the recipient of the external page's content. In it place any content and layout you like, and where you want the external HTML page to appear add the include.
<?php include('/path/to/included/page.html'); ?>
This path must be correct.
Name the page with the above code in it anything you like, as long as it ends with ".php".
Still having trouble? Post your code.

Reply With Quote
  #8  
Old 01-19-2009, 05:09 AM
iFuseRoss
Guest
 
Posts: n/a
If you create the following four files and place them in the same directory as each other, when index.php is visited, each of the following files will be included. There are several different types of includes. include(), include_once(), require() and require_once(). They're all used in the same way, simply specifying the filename as the parameter so include('header.html'), include_once('header.html'), require('header.html') and require_once('header.html'). The difference between include and require is that if you're using require, and the file isn't found, the page won't continue loading, however with an include, the page will just load without that include. The addition of _once simply checks if that file has already been included, and if so, doesn't include it again.
index.php
<?php include('header.html'); ?>
<?php include('content.html'); ?>
<?php include('footer.html'); ?>
header.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Page</title>
</head>
<body>
<div id="content">
content.html
<p>Any content placed in this file is positioned in between the <div id="content"> and the </div> tag in the header and footer, respectively.</p>
footer.html
</div>
</body>
</html>

Reply With Quote
  #9  
Old 01-19-2009, 03:22 PM
sithpigeon
Guest
 
Posts: n/a
Thanks, I'll work on it.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
50e60d71-40a8-4ceb-9b88-356345a799de Listing 2013-03-05 18:26:17
50d46ad4-7db4-42e5-ba39-4c2745a799bf Listing 2013-03-05 18:24:19
50d46ad3-cd68-4c75-8da2-4c1e45a799bf Listing 2013-03-05 18:24:17
50d46ad3-2118-4e13-a702-4c2245a799bf Listing 2013-03-05 18:24:18
Data Storage Corp. Partners with Document Automation Solutions Firm inFORM Decisions Web Hosting News 2012-01-05 16:26:16


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?