Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can an .html file use include()?

    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

  • #2
    Regular Coder
    Join Date
    Mar 2004
    Location
    Jackson, Georgia
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You need to addtype .html in your php.ini file
    Designer's Toolz; Web & software development community.

    Get your coding questions answered:
    DTZ Forums

  • #3
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 ?
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #4
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    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
    Last edited by miranda; 04-06-2004 at 09:47 PM.

  • #5
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    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

  • #7
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #8
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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.

  • #9
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #10
    Regular Coder dswimboy's Avatar
    Join Date
    Nov 2003
    Location
    mostly in Ann Arbor
    Posts
    458
    Thanks
    0
    Thanked 0 Times in 0 Posts
    does Yahoo! Stores support SSI? do they parse .html files? you could include your document that way, intstead of perl or php.
    "There is more than one way to do it."

  • #11
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    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.

  • #12
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    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 Code:
    <?php
    eval('?>' file_get_contents('dummy.html'));
    ?>
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •