PDA

View Full Version : Can includes be done in just regular .htm pages?


NickPapageorgio
04-23-2005, 02:17 PM
Or do you have to use php or shtml or some other extension?

gigi
04-23-2005, 02:21 PM
They can if you ask your host to set it up for you.....but I believe it puts extra strain on your server (not a WHOLE lot, but a little) so if speed is a huge issue, you may want to use .html....

Dravyk
04-23-2005, 02:23 PM
Server Side Includes (SSI) use CGI includes and most go to pages labeled .shtml

You can also do virtual includes using PHP, and they have to be called out on pages ending in .php

However, you can also have your server set up by your host (if they're amenable to it) to have your .shtml pages actually end in just .html (but really be .shtml). I am told you can also do this with PHP, however no host will do both because then it causes too much server drag to parse for both.

PornoDoggy
04-23-2005, 02:26 PM
It's a value set in your apache config ... otherwise, what they said about server load.

Grump
04-23-2005, 02:49 PM
If you put this line:

AddType application/x-httpd-php .php .phtml .php3 .html .htm .shtml

into the root .htaccess file it will allow .htm or .html files to be parsed so that includes can be used on them. It may slow your server down, lots of debate on how significant this is. I have used this for years now with no problems or noticeable difference in speeds.

helix
04-23-2005, 02:54 PM
here is a link to a SSI resource
http://bignosebird.com/ssi.shtml

Trev
04-23-2005, 03:02 PM
AddType text/x-server-parsed-html .html
AddType text/x-server-parsed-html .htm


I run with this in my root .htaccess and have had no noticable server load. :)

NickPapageorgio
04-23-2005, 03:21 PM
Ok and next question, what's the best way to write one out? I know the php way is pretty simple but does the html way vary much?

Trev
04-23-2005, 03:24 PM
Originally posted by NickPapageorgio@Apr 23 2005, 08:22 PM
Ok and next question, what's the best way to write one out? I know the php way is pretty simple but does the html way vary much?

This be it:

<!--#include virtual="whatever.txt" -->

Trev
04-23-2005, 03:30 PM
Not sure but I re-read your post and didn't know if you meant how to write the code to call the include or if you wanting to know how to write the include itself...

For any thing you're wanting to include in to your page just write the html or text and save it as .txt

venturi
04-23-2005, 05:58 PM
Rather than adjusting your httpd.conf or your root .htaccess to make all .html pages parsed for SSI, just add this to your .htaccess file:

XBitHack on

Then for any page(s) you want to parse for SSI, just change the permissions on that/those specific files to 0755.

Trev
04-23-2005, 06:07 PM
Originally posted by venturi@Apr 23 2005, 10:59 PM
Rather than adjusting your httpd.conf or your root .htaccess to make all .html pages parsed for SSI, just add this to your .htaccess file:

XBitHack on

Then for any page(s) you want to parse for SSI, just change the permissions on that/those specific files to 0755.
It's good, however isn't it a pain in the arse having to write the permissions for every page you use includes on?

I ask because I'd say at least 90% of my pages use includes so I'd rather just upload it and forget it.

venturi
04-23-2005, 06:15 PM
Originally posted by Trev+Apr 23 2005, 02:08 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Trev @ Apr 23 2005, 02:08 PM)</td></tr><tr><td id='QUOTE'> <!--QuoteBegin-venturi@Apr 23 2005, 10:59 PM
Rather than adjusting your httpd.conf or your root .htaccess to make all .html pages parsed for SSI, just add this to your .htaccess file:

XBitHack on

Then for any page(s) you want to parse for SSI, just change the permissions on that/those specific files to 0755.
It's good, however isn't it a pain in the arse having to write the permissions for every page you use includes on?

I ask because I'd say at least 90% of my pages use includes so I'd rather just upload it and forget it. [/b][/quote]
yeah, if you're talking about the majority of your pages using SSI then XBitHack isn't the best option. Might as well just add .html to the ServerParsed directive and pay the slight performance hit the server takes on your non-SSI pages.

But, if you've only got a few pages using SSI and you don't want to rename them to .shtml XBitHack is a great option, and the SE's aren't going to drop your already listed pages because you had to rename them. :agrin:

sarettah
04-24-2005, 02:05 PM
Hi guys :)

I have followed most of this, but I was wondering, for the benefit of those of us that might be less technically orriented...

Could you explain what it is that the stuff you are telling Nick to do does ?

I know that I have a cardinal rule to never include anything in my coding that I don't understand exactly what it is doing and why and I always recommend that folks follow that rule :)

Thanx in advance :)

Trev
04-24-2005, 02:31 PM
Originally posted by sarettah@Apr 24 2005, 07:06 PM
Hi guys :)

I have followed most of this, but I was wondering, for the benefit of those of us that might be less technically orriented...

Could you explain what it is that the stuff you are telling Nick to do does ?

I know that I have a cardinal rule to never include anything in my coding that I don't understand exactly what it is doing and why and I always recommend that folks follow that rule :)

Thanx in advance :)
Hahahahah :lol:

Yeah right :P

Ok here's what I think, correct me if I'm wrong oh techless one:

Once this is inserted in to the root .htaccess:

AddType text/x-server-parsed-html .html
AddType text/x-server-parsed-html .htm

The server will then parse every .html and .htm file that is called and check for virtual includes and include them before serving.


It’s very handy to use this for sponsor codes as you can change out hundreds of links by simply editing 1 .txt file.

sarettah
04-24-2005, 02:42 PM
Originally posted by Trev@Apr 24 2005, 01:32 PM
The server will then parse every .html and .htm file that is called and check for virtual includes and include them before serving.

What's a virtual include ? :blink:

Trev
04-24-2005, 02:46 PM
Originally posted by sarettah+Apr 24 2005, 07:43 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (sarettah @ Apr 24 2005, 07:43 PM)</td></tr><tr><td id='QUOTE'> <!--QuoteBegin-Trev@Apr 24 2005, 01:32 PM
The server will then parse every .html and .htm file that is called and check for virtual includes and include them before serving.

What's a virtual include ? :blink: [/b][/quote]
Don't you have some code to run through :lol:

sarettah
04-24-2005, 02:49 PM
Originally posted by Trev+Apr 24 2005, 01:47 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Trev @ Apr 24 2005, 01:47 PM)</td></tr><tr><td id='QUOTE'> Originally posted by sarettah@Apr 24 2005, 07:43 PM
<!--QuoteBegin-Trev@Apr 24 2005, 01:32 PM
The server will then parse every .html and .htm file that is called and check for virtual includes and include them before serving.

What's a virtual include ? :blink:
Don't you have some code to run through :lol: [/b][/quote]
lolol...nopers :)

Just working down the list here.

I had on there "update softball site" - check
"update weekend jewelry" - check
"update weekend-jewelry" - check
"bother Trev"
"go get rocks"


You were next on the list, what can I say :yowsa:

so, what's a virtual include ? :nyanya:

Trev
04-24-2005, 02:59 PM
Originally posted by sarettah+Apr 24 2005, 07:50 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (sarettah @ Apr 24 2005, 07:50 PM)</td></tr><tr><td id='QUOTE'> Originally posted by Trev@Apr 24 2005, 01:47 PM
Originally posted by sarettah@Apr 24 2005, 07:43 PM
<!--QuoteBegin-Trev@Apr 24 2005, 01:32 PM
The server will then parse every .html and .htm file that is called and check for virtual includes and include them before serving.

What's a virtual include ? :blink:
Don't you have some code to run through :lol:
lolol...nopers :)

Just working down the list here.

I had on there "update softball site" - check
"update weekend jewelry" - check
"update weekend-jewelry" - check
"bother Trev"
"go get rocks"


You were next on the list, what can I say :yowsa:

so, what's a virtual include ? :nyanya: [/b][/quote]
As long as your getting the rocks after me :lol:


A virtual include is html (or many other things) stored in a file that when referenced in a web page will be included as if it was directly written into the page. Even though it has been pulled from somewhere else entirely.

Trev
04-24-2005, 03:28 PM
Guess your getting the rocks :unsure:

sarettah
04-24-2005, 06:27 PM
Originally posted by Trev@Apr 24 2005, 02:29 PM
Guess your getting the rocks :unsure:
lolol...

yep, just got back a few minutes ago.

Didn't do quite a truck load but I think we now have enough for along the driveway (where my truck tires cut a ditch every winter) Our driveway has a little curve to it which looks real pretty but in actual use doesn't always work so well.

Trev
04-24-2005, 06:29 PM
Originally posted by sarettah+Apr 24 2005, 11:28 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (sarettah @ Apr 24 2005, 11:28 PM)</td></tr><tr><td id='QUOTE'> <!--QuoteBegin-Trev@Apr 24 2005, 02:29 PM
Guess your getting the rocks :unsure:
lolol...

yep, just got back a few minutes ago.

Didn't do quite a truck load but I think we now have enough for along the driveway (where my truck tires cut a ditch every winter) Our driveway has a little curve to it which looks real pretty but in actual use doesn't always work so well. [/b][/quote]
Thank fuck!!! I thought you went to get them to throw at me :blink:


How did I score in the quiz, I gave myself a 4 out of 15 for explanation :unsure:

sarettah
04-24-2005, 06:46 PM
Originally posted by Trev@Apr 24 2005, 05:30 PM
How did I score in the quiz, I gave myself a 4 out of 15 for explanation :unsure:
How the hell do I know. I was the one asking the question remember ? :yowsa:

Ok, ok, yes, I know what a virtual include does (although I have yet to use one) so your explanation was a good start, you sort of explained an "include" in there which of course a virtual include is an "include" and you sort of pointed out the difference between the two with "Even though it has been pulled from somewhere else entirely.".

I probably would have said that a virtual include is an include that allows you to include a file from outside the site path ie: other places on the server :)

But I don't think a non techie would get mine either :blink:

sarettah
04-24-2005, 06:47 PM
Originally posted by Trev@Apr 24 2005, 05:30 PM
Thank fuck!!! I thought you went to get them to throw at me :blink:

Why would I waste good rocks on that ?

I'm a Merican, I owns guns :groucho:

Trev
04-24-2005, 06:52 PM
Originally posted by sarettah+Apr 24 2005, 11:47 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (sarettah @ Apr 24 2005, 11:47 PM)</td></tr><tr><td id='QUOTE'> <!--QuoteBegin-Trev@Apr 24 2005, 05:30 PM
How did I score in the quiz, I gave myself a 4 out of 15 for explanation :unsure:
How the hell do I know. I was the one asking the question remember ? :yowsa:

Ok, ok, yes, I know what a virtual include does (although I have yet to use one) so your explanation was a good start, you sort of explained an "include" in there which of course a virtual include is an "include" and you sort of pointed out the difference between the two with "Even though it has been pulled from somewhere else entirely.".

I probably would have said that a virtual include is an include that allows you to include a file from outside the site path ie: other places on the server :)

But I don't think a non techie would get mine either :blink: [/b][/quote]
:huh:

You must be joking when you say you don't use includes!?!?!

How do you update pages without really updating them :groucho:

Trev
04-24-2005, 06:55 PM
Originally posted by sarettah+Apr 24 2005, 11:48 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (sarettah @ Apr 24 2005, 11:48 PM)</td></tr><tr><td id='QUOTE'> <!--QuoteBegin-Trev@Apr 24 2005, 05:30 PM
Thank fuck!!! I thought you went to get them to throw at me :blink:

Why would I waste good rocks on that ?

I'm a Merican, I owns guns :groucho: [/b][/quote]
Bugger I used the same groucho.

Guns don't worry me, it's the smell of petrol that gets me :unsure:

sarettah
04-24-2005, 06:59 PM
Originally posted by Trev@Apr 24 2005, 05:53 PM
You must be joking when you say you don't use includes!?!?!

How do you update pages without really updating them :groucho:
Who updates ? :blink:

Trev
04-24-2005, 07:04 PM
Originally posted by sarettah+Apr 25 2005, 12:00 AM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (sarettah @ Apr 25 2005, 12:00 AM)</td></tr><tr><td id='QUOTE'> <!--QuoteBegin-Trev@Apr 24 2005, 05:53 PM
You must be joking when you say you don't use includes!?!?!

How do you update pages without really updating them :groucho:
Who updates ? :blink: [/b][/quote]
Ok :huh:

icq me :unsure:

Dravyk
04-25-2005, 02:26 AM
Originally posted by sarettah+Apr 24 2005, 06:00 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (sarettah @ Apr 24 2005, 06:00 PM)</td></tr><tr><td id='QUOTE'> <!--QuoteBegin-Trev@Apr 24 2005, 05:53 PM
You must be joking when you say you don't use includes!?!?!

How do you update pages without really updating them :groucho:
Who updates ? :blink: [/b][/quote]
No banner systems?! :blink:

sarettah
04-25-2005, 06:24 AM
Originally posted by Dravyk+Apr 25 2005, 01:27 AM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Dravyk @ Apr 25 2005, 01:27 AM)</td></tr><tr><td id='QUOTE'> Originally posted by sarettah@Apr 24 2005, 06:00 PM
<!--QuoteBegin-Trev@Apr 24 2005, 05:53 PM
You must be joking when you say you don't use includes!?!?!

How do you update pages without really updating them :groucho:
Who updates ? :blink:
No banner systems?! :blink: [/b][/quote]
whats a banner ? :blink:

Trev
04-25-2005, 06:26 AM
Originally posted by sarettah+Apr 25 2005, 11:25 AM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (sarettah @ Apr 25 2005, 11:25 AM)</td></tr><tr><td id='QUOTE'> Originally posted by Dravyk@Apr 25 2005, 01:27 AM
Originally posted by sarettah@Apr 24 2005, 06:00 PM
<!--QuoteBegin-Trev@Apr 24 2005, 05:53 PM
You must be joking when you say you don't use includes!?!?!

How do you update pages without really updating them :groucho:
Who updates ? :blink:
No banner systems?! :blink:
whats a banner ? :blink: [/b][/quote]
Hahahahaha :lol:


I can't wait till we get to: what's a message board? :blink:

Dravyk
04-25-2005, 09:06 AM
Originally posted by Trev+Apr 25 2005, 05:27 AM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Trev @ Apr 25 2005, 05:27 AM)</td></tr><tr><td id='QUOTE'> Originally posted by sarettah@Apr 25 2005, 11:25 AM
Originally posted by Dravyk@Apr 25 2005, 01:27 AM
Originally posted by sarettah@Apr 24 2005, 06:00 PM
<!--QuoteBegin-Trev@Apr 24 2005, 05:53 PM
You must be joking when you say you don't use includes!?!?!

How do you update pages without really updating them :groucho:
Who updates ? :blink:
No banner systems?! :blink:
whats a banner ? :blink:
Hahahahaha :lol:


I can't wait till we get to: what's a message board? :blink: [/b][/quote]
You all scare me! :ph34r:

Robert
04-26-2005, 06:17 PM
Originally posted by Trev@Apr 23 2005, 02:25 PM

This be it:

<!--#include virtual="whatever.txt" -->
Can whatever.txt be on a different domain? If so, any drawbacks?

Grump
04-26-2005, 06:54 PM
It can be on a different domain on the same server if you use the server path in a php call, not sure about from a different server.

<? include("/home/username/domainname/foldername/filename.txt"); ?>

EDIT- I think it can also be done across domains on the same server without php using a virtual folder.

Trev
04-26-2005, 07:04 PM
Originally posted by Grump@Apr 26 2005, 11:55 PM
It can be on a different domain on the same server if you use the server path in a php call, not sure about from a different server.

<? include("/home/username/domainname/foldername/filename.txt"); ?>

EDIT- I think it can also be done across domains on the same server without php using a virtual folder.
I use an include folder like you say in my root to pull the includes for my domains.

Includes as far as I'm aware need to reside on the same server.

Robert
04-26-2005, 07:09 PM
Thank you. :okthumb:

Jeremy
04-27-2005, 03:55 AM
Originally posted by Grump@Apr 26 2005, 02:55 PM
It can be on a different domain on the same server if you use the server path in a php call, not sure about from a different server.

<? include("/home/username/domainname/foldername/filename.txt"); ?>

EDIT- I think it can also be done across domains on the same server without php using a virtual folder.
It depends on how your server is set up :-0)

There are times when it's advisable to have php includes outside of the web root (usually /html/), so you can only include it like:

<? include("/home/path/to/file"); ?>

Most common these days is to slap it in a folder inside the web root, so you can use relative or absolute linking as you would any other file on the server.

Relative:
<? include("/path/to/file"); ?>

Absolute:
<? include("http:www.domain.com/path/to/file"); ?>

(NB: this will allow it to be linked to from *any* domain, on-server or off-server - it can cause probs because php can only handle a certain amount of full URL connections).

If you have multiple domains on a server but only want to have one folder serving all the includes, you can either call it all from one location (/home/path/to/file) or you can be sneaky and alias /symlink a folder so it can be relative across all domains. You can do this in htaccess but it's better to alias stuff in apache config.

EG in your html you'd include "/includefolder/file" which would to all intents and purposes be served from domain.com/includefolder/file but in reality is served from /some/other/location/includefolder/file

sarettah
04-27-2005, 08:42 AM
Originally posted by Jeremy@Apr 27 2005, 02:56 AM
you can be sneaky and alias /symlink a folder so it can be relative across all domains.
The Sims got links all over the damn net already, we don't have to give them any more DAMMIT ! :blink:


I hate the SIMS :grrr:

D-man
04-29-2005, 01:12 AM
you can also do .js includes on a .html and that does not require any .htaccess mods - on the down side if your doing say a tgp gallery you won't get listed with a js script on your page