team1504 — 2012-01-20T18:52:50-05:00 — #1
I was hoping someone could help me figure out why my html include was not working. In a previous thread, a while ago, I was told one can include html from another file using the following syntax: <!--#include virtual="pathToFile.html" -->
Is that I am trying to use html includes in the following, and much simpler example, but the point is that they don't seem to be working.
I have an index.html, which has the following syntax and a live copy is up here:
<title>Red bg on no script</title>
<!--#include virtual="include.html" -->
and the file it includes is up here and the contents of that file is:
So when one views index.html, shouldn't the include be included and the body's background be set to red?
Does anyone have any ideas on how to fix this?
kohoutek — 2012-01-20T19:07:25-05:00 — #2
What programming language are you using for the include?
<!--#include virtual="include.html" --> ???
imaginekitty — 2012-01-20T20:01:37-05:00 — #3
What happens if you change the file extension to .shtml as in index.shtml
Basically, you have to be sure that your server is set up to process SSI, then you have to tell it to look for includes by using the correct file extension.
ralphm — 2012-01-20T20:19:31-05:00 — #4
A nicer solution (IMHO) is to use PHP includes, but your pages need to have a .php extension (well, you can avoid that, but there's not much point generally). Anyhow, try what imaginekitty suggests anyway, so you at least know what the issue is.
team1504 — 2012-01-20T22:05:05-05:00 — #5
@kohoutek: just normal html.
I don't know, i will try it tomorrow.
But isn't it already looking for the correct file-extension ?
The suggestion you made applies to the file calling the include (index.html in my example) not the file to be included (include.html), right?
@ralph_m: What does IMHO mean?
wait, a file using php includes can not have a .php extension?
imaginekitty — 2012-01-20T22:19:53-05:00 — #6
Wait, what? ?? If you have a php file but you call it index.html it just serves it without processing it because the server doesn't know to process it as a php file. Same thing with SSI. It doesn't know to use includes because you didn't use the proper file extension. It's just serving it as is.
Wait, what? ??
ralphm — 2012-01-21T02:10:53-05:00 — #7
IMHO, it means In My Humble Opinion. Get with the web lingo, man! :lol: (It's all kinda new to me, I admit. Too old for this kid talk. )
wait, a file using php includes can not have a .php extension?
You can tell your server to process PHP in .html files by adding this to your .htaccess file:
AddType application/x-httpd-php .html
imaginekitty — 2012-01-21T02:58:15-05:00 — #8
I was going to see if SSI works and then pop a php_info (); on him.
Ultimately, above either, my suggestion would be ASP.NET MasterPages but it may not be necessary.
technobear — 2012-01-21T07:30:37-05:00 — #9
Me too - but you can look trendy with the help of http://www.acronymdb.com/ :D[/ot]
team1504 — 2012-01-21T12:09:18-05:00 — #10
I have no idea What I meant. I think it was a confusing way to ask the second question I asked you (confirmation on which file will have the .shtml extension).
Haha. I know that feeling. I found abbreviations and emoticons for things/words ive never heard of. Idk, btw,and ttyl are enough for me.
wait, wouldn't that prevent the server from processing PHP in .php files? Or should the line be:
AddType application/x-httpd-php .html, .php
team1504 — 2012-01-21T12:13:06-05:00 — #11
Haha nice. Thank you for the link @TechnoBear— ill have to take a look at that!
Btw, how do you do the off topic highlight? I have seen it a few times on the forums, but never asked how to do it.
imaginekitty — 2012-01-21T12:14:26-05:00 — #12
Ah. The calling file should have the special file extension. The include file can be anything, even .txt or .inc or .blah, as long as it matches the file in the include statement.
technobear — 2012-01-21T12:54:04-05:00 — #13
You wrap it in [ot] opening and closing tags which, AFAIK (= as far as I know :lol:) you need to type yourself - there isn't a button.
imaginekitty — 2012-01-22T19:59:32-05:00 — #14
Tomorrow was yesterday. Ahoy, ahoy?
team1504 — 2012-01-23T11:13:42-05:00 — #15
Apologies, I had a busy weekend and I guess I went a little too off topic. Speaking on which, thank you @TechnoBear for teaching me how to highlight off-topic (parts of) posts.
Back on topic, i tried changing index.html to index.shtml and opened it again in chrome and the background was not red. So that means that the include did not work properly, right?
Here are new links to the files as I changed the extension of index.html to index.shtml (so the old links won't work):
Sorry for keeping you, @imaginekitty waiting much longer than it should have been .
imaginekitty — 2012-01-23T13:37:45-05:00 — #16
Ain't no thing.
OK, see it does work on my server: http://imaginekitty.com/team1504.shtml (I made no changes except for the file names)
Is dropbox.com your only host? You'll have to use a proper host to get such functionality.
I doubt they offer PHP but try making a page called test.php and make the contents of the file exactly this:
<?php php_info() ?>
Upload it and go to that page using your browser to see if it works.
team1504 — 2012-01-23T14:04:32-05:00 — #17
it doesn't work. Dropbox doesn't support PHP. But if it works now on your sever then I trust that it will work on my actual server.
Once i make the changes and upload the site, if i have questions, do you mind if i PM you?
Also if and when @ralph_m is online can he or anyone else answer my question on the line to add to the .htacess file to get php parsed in .html files?
Here it is again:
imaginekitty — 2012-01-23T14:13:36-05:00 — #18
I don't think you really want .html files parsed as PHP. Just because you can doesn't mean you should.
team1504 — 2012-01-23T16:39:20-05:00 — #19
well i just wanted to know how to do the .htacess change properly for learning sake.
But why wouldn't i? I know that you be a dangerous questions to ask, but it seems like an okay solution.
i think a bad thing about it is that i have to change the .htacess file.
Meaning, my HTML document will be parsed as html, as html in a php document outside of the <?php ?> tags is, and the includes will be parsed as PHP— i don't see any issues with that.
ralphm — 2012-01-23T18:28:12-05:00 — #20
I probably shouldn't make comments on stuff I don't understand well enough. :lol: That line used to work for me when I had PHP on a .html page (for testing only, as I don't do it in real life) but on my new server it doesn't work, so so much for that. I gather different servers require different .htaccess code, but none of the ones I've seen work on my new server (I've just tested them). So now I can't test whether not having the .php in the htaccess rule stops PHP working on .php pages or not. Sorry!
next page →