Jump to content
xisto Community
Sign in to follow this  
switch

Integrating One Html File Into Another without embedding

Recommended Posts

The main reason why i don't want to do that is because it sorta slows things down a bit.

Usually the amount of slow down is so small as to be almost unnoticeable.
I don't know if Xisto is configured to accept includes in HTML documents but it is for PHP documents. Don't worry if you don't know any PHP. Just create your page as you would normally, but instead of saving it as .html, save it as .php and then where you want to include the code that is to appear on all pages put:

<?php include('myInclude.htm') ?>
And that's it. :) To give you an example, a site I created recently looked like this:

<?php include('header.php') ?>Content for individual page<?php include('footer.htm') ?>
Every page looked like that except for the different content in the middle.

Share this post


Link to post
Share on other sites

Wow that's very helpful. Normally I use iframes because I didn't know of anything else to use. Of course iframes didn't help much to validate my site. lol This is more efficient. Thanks everyone.

Share this post


Link to post
Share on other sites

amsho,* * * NEWS FLASH ***Problem with viewing your source is: there is no php in the page by the time it gets to my browser. It is Html code so my browser can display it. Why don't you post a code snippet here for others to have a look?

Share this post


Link to post
Share on other sites

Tyssen's point about client side 'includes' being able to be turned off is very valid. It seems more and more people are wary of javascript and will turn it off as a security precaution. Where possible you are definitely better off to use server side includes. This doesn't mean client side includes don't have their place, use them when server side includes such as PHP or ASP etc are not available.PHP is an easy and powerful language to use, even an old man like me can learn to use it. If you have it available like you do here at Xisto, make the most of it.As for slowing down the page by using includes, I don't think it would matter which way you do it, the page loading would be much the same. Generally it's basically on text of html that you are including so it be a similar load to actually writing the code on the one page.

Share this post


Link to post
Share on other sites

hey, come to think of it, would there be a way to include little side fragments like for a side contents bar or something? that's another thing i'm trying to do. I can think of a way that involves include-ing into tables, but tables are really bad for design...also, the parts in between the PHP include statements, are they just written in standard HTML? if so, where does the <HTML> tag come in? before the PHP or after? I'm guessing it comes in at the top of the header file.thanks for all your support everyone.

Share this post


Link to post
Share on other sites

also, the parts in between the PHP include statements, are they just written in standard HTML? if so, where does the <HTML> tag come in? before the PHP or after? I'm guessing it comes in at the top of the header file.

You can put whatever you want between the includes. Same as in the includes themsevles. An include can also just be a single line of code if you want it to be - it doesn't have to be a large chunk of code like a header.
The reason I laid out my previous post the way I did is cos I'm guessing you don't know much PHP yet and are wary of using PHP includes for that reason. I was just trying to show how you how easy it is to use them without knowing much PHP.
In reality, my header include is a bit more complicated than that cos I've actually included it in a function which can receive different variables from different pages to change the title, meta description and other lines of code too. But it doesn't have to be any more complicated than simply pasting HTML into it.

Share this post


Link to post
Share on other sites

They work in a very similar way to the js method you posted. You create a file with the piece of code that's to be inserted into another file and then you write a line of code in that file that calls the include. For PHP it looks like this:

 

<? php include('yourfile.htm') ?>
In ASP and HTML it looks like this:

 

<!-- #include virtual="/yourfile.htm" -->
Some configuration of the server is required to get it to work for HTML as it is not usually enabled by default. PHP, ASP, JSP, Coldfusion etc. all enable them by default.

You can call any file to include in your document: .htm, .txt, .inc, .asp, .php. In fact, you can write scripting code in a .txt file and it'll work as intended if it is included in a file with the relevant extension (e.g. .asp or .php).

I'm not aware of any restrictions (except if you're server isn't configured to accept them which wouldn't be the case if you're using Xisto). The benefits over the js method is that they can't be turned off and rather than being written to the page as javascript, they get written as HTML (or whatever else you've included).

209338[/snapback]


<? ?>

PHP include statement. The file name extension should be .php

 

<!-- #include virtual="/yourfile.htm" -->

SSI include statement. The file name extension should be .shtm or .shtml

Share this post


Link to post
Share on other sites

<? ?>PHP include statement. The file name extension should be .php

<!-- #include virtual="/yourfile.htm" -->
SSI include statement. The file name extension should be .shtm or .shtml

No, that's incorrect actually - you can include any sort of file, even .txt files. The file calling the include must have the correct file extension, but it doesn't matter for the include itself.

Share this post


Link to post
Share on other sites

So then the follwing code should work if it is saved into an shtml file, but it doesn't.

<!-- #include virtual="/home/jlhaslip/public_html/testinclude/header.html"--><h2>Content here h2 </h2><!-- #include virtual="/home/jlhaslip/public_html/testinclude/footer.html" -->

Are there any corrections that should be made to the syntax?
It works okay if I use the php version.

And in the php file, the full path must be in the include. I tried several other paths and this is the one that works. Shortening it to '/testinclude/header' fails as do all the ones in between.

Share this post


Link to post
Share on other sites

Okay, thanks for the answer Tyssen, however, by way of PM from Buffalohelp, I have information which suggests I stop with this Html Include stuff because Xisto.com does not support them. Now that I know this, I will continue with php includes only.(apperently, Html includes is a MS ASP construct and Xisto is Linux, so that's why they aren't supported here.)

Share this post


Link to post
Share on other sites

Okay, thanks for the answer Tyssen, however, by way of PM from Buffalohelp, I have information which suggests I stop with this Html Include stuff because Xisto.com does not support them. Now that I know this, I will continue with php includes only.
(apperently, Html includes is a MS ASP construct and Xisto is Linux, so that's why they aren't supported here.)

I actually wrote a post that said something like that the first time, but something happened and it didn't get posted, so the 2nd time around I just went for the quick approach. :blink:

Share this post


Link to post
Share on other sites
Dependences on web server Apache or IIS and configuration of serverIntegrating One Html File Into Another

No, that's incorrect actually - you can include any sort of file, even.Txt files. The file calling the include must have the correct fileExtension, but it doesn't matter for the include itself.

That is wrong it depends on webserver configuration and brand like PHP on IIS or PHP on Apache is so diferente.winner example page

-reply by Winer RealesKeywords: it is possible to put html form in another one

Share this post


Link to post
Share on other sites
My question is what if you are NOT using a server???Integrating One Html File Into Another

I send out a Christmas CD each year... The user puts it into the PC and it autoloads index.Html which starts the show. It's all contained on the CD... No internet connection needed. In the past I used frames where the first loaded the menu on the left and the main page on the right. Wanting to get away from frames... I was wondering how I could write one menu.Html page and have it automatically pulled into the rest of the pages.

 I'm thinking there would be a DIV that would be on the left... And another on the right. I don't even mind using a table with two cells... And loading the menu on the left and the main page on the right. Clicking the menu would open a new page that would also contain the same menu.

The problem is... No server, no ASP, no PHP... Just a CD loading pages.

Can it be done?

Thanks,

Jerry

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.