Click to See Complete Forum and Search --> : incorporating files into a page


ozzga
12-24-2002, 09:57 PM
hey, i would like to put the coding for my menus in a seperate file and link them to the page, in order to make changes sitewide by only modding one file... any way to do this?
TIA

pyro
12-24-2002, 11:06 PM
Does your server support SSI (Server Side Includes)? If so you can make a HTML file with your menu in it and link to it on your pages with an SSI that looks like this.

<!--#include file="menu.htm"-->

You will probably have to rename your pages to .shtml

ozzga
12-25-2002, 11:19 AM
tried it, didn't work... but then again i just put in some text, no html tags. oh my server has this:
Active CGI Directory w/ SSI
is that what you're taking about?

aepstar
12-25-2002, 12:05 PM
yes and then u place this line

<!-- include file="menu.htm"-->

and the actual menu.htm must be in a same dir and contain html tags. ie: <a href="lol.htm">hi geek</a>

so not wif <html> and head tags coz u have dem already in ur file

peace man!

ozzga
12-25-2002, 02:55 PM
nope, still not working. you can take a look at it here:
test page (http://aquasyst.rockin.net/love_your_neck/test.shtml)

anyone know of another way to include files??

aepstar
12-25-2002, 03:32 PM
<!--#include virtual="menu.htm" --> or <!--#include file="menu.htm" -->

save the main file as .shtml and if still not working contact ur host

Craiga
12-25-2002, 07:08 PM
Blah blah, heres an easier way. Just put you javascript into a file. Say all your coding is like this:

Menu('menu1');
Menu('menu2');
Menu('menu3');

And thats your menu code. Put this into a file and name it whatever you want with the end extension .js. So you can name it menus.js, Then in your body tag or whever you need it just include it:

<script language="javascript" src="menus.js"></script>

Then you can do the rest of your stuff. Just make sure not to put and code in between the above script tags cause it won't work. You need to make two new tags.

pyro
12-26-2002, 09:19 AM
Originally posted by Craiga
Blah blah, heres an easier way. Just put you javascript into a file.

This will only work for 12% of web users.

If you server supports SSI, you'd be better to try to figure that out. It is also possible that your SSI needs to be in a certain directory. I'd contact your host and see what they can tell you.

Craiga
12-26-2002, 09:50 AM
How do you figure?? 12%? More than 12% use IE6 and that supports it.

pyro
12-26-2002, 09:56 AM
My bad. This will NOT work for 12% it will work for 88%. Sorry about that.

Charles
12-26-2002, 10:09 AM
Originally posted by Craiga
How do you figure?? 12%? More than 12% use IE6 and that supports it. But quite a few MSIE 6 users turn off the scripting. Microsoft has more than 88% of the market but only 88% use JavaScript.

Craiga
12-26-2002, 10:30 AM
I see. I knew that some people turn it off, but i didn't know how much, wouldn't see why you would want to.

jeffmott
12-26-2002, 10:59 AM
wouldn't see why you would want to

Because many people abuse JavaScript to change user's browser settings or just bombard them with pop-ups.

Craiga
12-26-2002, 11:08 AM
True, but it makes webpages really ****ty, like you wouldn't see anything on my site without javascript.

ozzga
12-26-2002, 11:55 AM
Originally posted by aepstar
<!--#include virtual="menu.htm" -->

ok that worked, thanks much for your help! this will make my life a whole lot easier. :D

and on a side note, it's always a good idea to make your site's content accessible to those without javascript. you may lose some of the flashiness or ease of use, but at least it's there.
which leads me to:
this file incorporating thing is done by the server, so it doesn't matter what the visitor is using right?

thanks again.

pyro
12-26-2002, 12:18 PM
Originally posted by ozzga
which leads me to:
this file incorporating thing is done by the server, so it doesn't matter what the visitor is using right?

Correct. Basically what the SSI is doing is substituting the <!--#include virtual="menu.htm" --> with your content. View the source of your page after you use the SSI call. It will look like the menu is right there.

One thing... Didn't <!--#include file="menu.htm"--> work for you? If it does, that is the way you should do it. <!--#include virtual="file.htm"--> has been depreciated, I believe.

Charles
12-26-2002, 12:40 PM
<!--#include virtual="file.htm"--> has been depreciated, I believe.It's the other way around. <!--#include file="" --> and <!--#include cgi="" --> were both depricated in favour of <!--#include virtual="" -->.

pyro
12-26-2002, 02:16 PM
Hmm... You're probably right. I thought I heard it was the other way around. :D

Charles
12-26-2002, 02:32 PM
Happily, it doesn't matter; whatever works works.