...

View Full Version : Call HTML into another page?



martynball
04-03-2009, 05:04 PM
Hello. I was wondering if there was a way I could make a webpage import html from another file into a page. E.g.

index.html:


<import html="1.html">
<import html="2.html">
<import html="3.html">
ect...


1.html:


<div class="main-content">
blahblahblah
<img src="url">
blahblah
</div>


This will make it ALOT easier to maintain and update. And will make the code on the main page much easier to see, because I want to add a lot of images. I know that forums use php to call in different style sheets. Something like @import.

abduraooft
04-03-2009, 05:20 PM
If you have a php or some other serverside support, it's very easy.

<?php
include "1.html";
?>
But the above code should be in a page having a .php extension, otherwise you'd need to add some htaccess rules to for your server to treat your html files like your php files

martynball
04-03-2009, 05:23 PM
Do you know what htaccess rules I need to add. And where do I put that php code? Because I want it to add the other files in certain places. Well, In a table.

So would I add



<?php
include "1.html";
include "2.html";
include "3.html";
?>
ect...


Between the <td></td> tags?

abduraooft
04-03-2009, 05:36 PM
Between the <td></td> tags? Yes, if it's in a php file,

<td><?php include "1.html";?></td>
...............
<td><?php include "2.html";?></td> should work.

PS: Do you know why tables for layout is stupid (http://www.hotdesign.com/seybold/)?

martynball
04-03-2009, 05:53 PM
I have seen that website to many times Lol. I know tables are bad, but I am a very basic coder Lol. I cant be bothered learn stuff like that yet.

Could I just save my page as a php file like it is? Or would I have to change stuff about?

SurFeR
04-03-2009, 06:49 PM
if you change your page extension as .shtml yo can include another file into your page
use that code to include a file:

<!--#include file="addedfile.html" -->

for more info about shtml click here (http://en.wikipedia.org/wiki/Server_Side_Includes)..

Rowsdower!
04-03-2009, 09:36 PM
You only need to work with the htaccess file if you are changing the way the HTML documents are served. If you're using plain PHP (as in "page.php" instead of "page.html") you won't have to bother with the htaccess file at all.

Before you look too heavily into PHP though, have you made sure that PHP is available on your hosting server? If not, you might have to resort to javascript. :(

martynball
04-03-2009, 11:24 PM
I will probably be using x10 hosting, they have php. It is all working now as well. Thanks people.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum