...

View Full Version : Can an .html file use include()?



OutshineNM
04-06-2004, 09:13 PM
Hello,

I have successfully used php include() in the past, but in order for it to function properly the file that contained the include was .php. Unfortunately, I'm creating a site that has to have an .html extension.
If I create the file with a .php extension it includes everything wonderfully, as soon as I change it to .html it just ignores the include commands.
Does anyone know how to include a file into an .html page?

Thanks!

Luke

DesignersToolz
04-06-2004, 09:31 PM
You need to addtype .html in your php.ini file

raf
04-06-2004, 09:32 PM
Welcome here!

The include() isn't executed because the .html file isn't parsed. You could configure your server to parse all .html pages (just like it now parses .php files). This will of course mean you'll do a lott of useless parsing, but unless it's a highly used webserver, then you'll ever notice it.

Anty reason why this page can't be a .php file ?

miranda
04-06-2004, 09:37 PM
have you tried using .shtm or .shtml? Note: as mentioned by the above posters, this will only allow you to include static html into your pages and not .php or asp content

You may have to make these changes in your .htacess file to allow use of the server side include.
AddType text/html .shtml .shtm
AddHandler server-parsed .shtml .shtm

to make it so that includes work in .htm .html files make the following change
AddType text/html .shtml .shtm .htm .html
AddHandler server-parsed .shtml .shtm .htm .html

OutshineNM
04-06-2004, 09:45 PM
Thanks for the replies!

I'm creating a merchant site for a client who is using Yahoo Store. They have an interface that the client uses to add their products and product information. Yahoo has their own "Store Tag" system with specialized tags unique to Yahoo that pull information regarding specific products from their database and write it to the html page.
Unfortunately, they are claiming that their server only parses .html files in the neccessary manner to translate the "Store Tag" system.
Also, a big downside with working with such a large system is I think the possibility of getting them to parse all html files for php is next to nill. :P

Miranda - No, I haven't tried .shtm or .shtml. I'm not real familiar with that. All this server-side stuff is pretty new to me, I'm a Javascript and Actionscript guy at heart.
Is the .htaccess you mentioned something each user account on a server would have, or is it system-wide?

Also, the only reason I'm using .php includes here is for the menuing system.
It's a fairly large ECommerce site that they will be updating and changing often. If anyone else knows of another way to accomplish the same result without .php includes, your input would be appreciated.

Thanks for all your help!

Luke

miranda
04-06-2004, 09:53 PM
look in your root directory for the following file .htaccess if it doen't exist then create a text file, inside that text file type one of the following

AddType text/html .shtml .shtm
AddHandler server-parsed .shtml .shtm
or
AddType text/html .shtml .shtm .htm .html
AddHandler server-parsed .shtml .shtm .htm .html


now save it as .htaccess and put it into your root directory.

if it does exist add the above code to the text file. You should be able to process the include files as long as the file is static html and does not have any .php coding

OutshineNM
04-06-2004, 10:01 PM
Miranda - The server isn't allowing me to 1. upload a file named .htaccess or 2. change a filename to .htaccess.

Just telling me permission denied, so I'm assuming those corporate suits at Yahoo don't want me touching it. Would it be worth giving them a call and seeing if they will change it for me? Thanks!

Luke

Nightfire
04-06-2004, 10:04 PM
I've seen this asked before at other forums and from the replies I've seen, you can't use any serverside language on yahoo stores. It that's true or not, I have no idea.

OutshineNM
04-06-2004, 10:10 PM
Well, I know they support PHP and Perl. My Include() script works fine, it's just that yahoo won't parse .html files for php and it won't parse anything but .html files for the yahoo proprietary store tags.

Luke

dswimboy
04-07-2004, 12:09 AM
does Yahoo! Stores support SSI? do they parse .html files? you could include your document that way, intstead of perl or php.

gbulmash
04-12-2005, 06:27 PM
In my experience, Yahoo stores will parse *one* SSI "include virtual" in a file, but it will truncate the page at the next call to a store tag. So unless you're using it for a footer, you want to avoid using SSI.

But if you're not dynamically generating the contents of the included file (i.e. it's just a static html file), you can put it in your catalog and use a store tag to include it.

Go to the table editor in your catalog manager section. Edit the default table and add a custom field. Give it a name like MyHeader, then give it a type of big-text and don't require it. Save the table.

Now, go into your catalog and create a new item. Call it say "htmlholder". Fill out the required fields, make it unorderable and untaxable, and put the contents of the file you wanted to include in the MyHeader field.

Save the item and publish the changes to your catalog.

In the HTML file you'll use on the site, use the following store tag...

<!--#ystore_catalog id=htmlholder field=MyHeader format=html -->

It's a bit of a roundabout way to do things, but it works. Also note that you can generally add up to a few dozen custom fields like this, so if you need multiple static file includes, they're available.

Hope this helps.

marek_mar
04-12-2005, 11:50 PM
My server parses the HTML file even though I didn't set anyting. It is logical in som way as you can include tpl/inc file without telling the srever that they should be php files.

This may be a dogy way to do it but... you might try that:


<?php
eval('?>' . file_get_contents('dummy.html'));
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum