Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SSI - I'm a beginner and need direction! 6

Status
Not open for further replies.

JennyW

Technical User
Mar 1, 2001
323
CA
SERVER SIDE INCLUDES

I want to make a site that has loads of pages.
The borders, menu and logo of this site are all images and all appear on every page on my site.

Right now, if I don’t use SSI and if I want to make changes to any re-appearing images on my site then I’d have to edit those changes individually - on every single page.

However, if I do use SSI, then I can edit those images once and my changes will be applied to every page.

I’m not too sure how I can go about doing this. Does anyone know how I can get started?

Note: I’m not running my scripts with Apache. I’m running them on my hosts server.

Thanks for reading,
Jenny
 
Have you considered using Frames? I get the feeling from some other posts on this site that 'Frames' is analogous to another F word but I like them. They'll give you your header and menu no problem.

Does 'my hosts server' mean that you've got a third-party supplying you with web services? If so they may want more money to allow SSI. Could be worth checking out.

WebMonkey is a great site with tutorials for all sorts of web stuff. Try this link:

I'd go with Frames though.
Kactus
 
If your web host supports PHP, I would try and use that. I just started using PHP about a month ago and really love it. You can include files with the code for your header and menu in each of your pages, and the server puts it all together for the user. If you update the images, menus, etc then all you have to do is change the single include file.
 
Hi,

to include files in your html pages using ssi just do:
<!-- #include file=&quot;relative_path/filename&quot; -->

just place the html you want to appear in all pages in text files and include them where you want the content to appear.

Bye.
 
Hiee!

This is how I’m understanding SSI:

1. I read that if I want specific html to display on a page I have to take that html and put it into a .txt file.
Then I insert that .txt file in my SSI call. Here’s an example:

<!--#include file=&quot;myfile.txt&quot; --> or <!--#include file=&quot;myfile.html&quot; -->

As you can see the second example above has an .html extension. I read you should only use .txt files within SSI calls, but some people use .html files. I couldn’t find the reason why. Does anyone know?

2. All of my websites pages use the same images (menu, header, footer, border).
However, some of my images have links on them and roll-over effects etc.
For example:
My Menu consists of several images. I understand that I can put all of my menu’s code and insert it in a .txt file and call it with an SSI command in all of my pages, but…

…what if some of the images on my Menu need code that’s in the < head > tag to function properly?

I know I don’t include the < html > < head > < title > and < body > tags in my .txt docs.

So, this is what I’m thinking…
I just insert the code for my menu in a .txt file (regardless of how many images and functions it has) and I leave the < head > code in the < head > tag of each pages original document (not the .txt doc).

This way when the SSI command calls the .txt file then the menu will function correctly because the html from that .txt file will be inserted into the html page, now that the html is part of the page it will then look for the < head > tags code in the original document.

Wooo. Am I right?

==================================

Yahve, you wrote…

to include files in your html pages using ssi just do:[/b]
<!-- #include file=&quot;relative_path/filename&quot; -->


Do I have to use include file? I read about something called Include Virtual.

Include Virtual
If you wish to place an .shtml file in one directory and have it call a header.txt file or any file in another directory, use the include virtual= command to accomplish this. The syntax is <!--#include virtual=&quot;/header.txt&quot; -->. Note that there is now a slash before the /header.txt file name this is calling the header.txt file in the user's home directory from any other directory.

Have you heard of this before? Can I use the virtual method if my .txt files are in the same directory as my html files?

==================================

Kactus, you wrote,
Have you considered using Frames?
I’ve very familiar with frames and have tested them on my site. They don’t suit it well.

Does 'my hosts server' mean that you've got a third-party supplying you with web services?
Yes, I have a host and everything is going well with them!!

My fingers are going to fall off.

Thanks so much!
Jenny
 
hie Jenny,
…what if some of the images on my Menu need code that’s in the < head > tag to function properly?
why dont use xtrnl js file? (<script src=&quot;menu.js&quot;></script>) regards, vic
 
Hi Jenny,

file vs virtual is quite simple:
virtual defines a virtual path to a document on the server.
file gives a pathname relative to the current directory.
I usually use file.

I think that vituz is right, you should use external scripts file. What I usually do is call scripts from external files if they're used on more that one page. This way, they only download once.

Bye.
 
Hi everyone!

Vituz, you wrote:
why dont use xtrnl js file? (<script src=&quot;menu.js&quot;></script>)

What is xtrnl js file (<script src=&quot;menu.js&quot;></script>)?

yahve, you wrote:
file vs virtual is quite simple:
virtual defines a virtual path to a document on the server.

What is a virtual path?

yahve, you also wrote:
I think that vituz is right, you should use external scripts file. What I usually do is call scripts from external files if they're used on more that one page. This way, they only download once.

I don’t understand? How do the external files only download once if you’re calling them on all of your webpages?

And what is an external scripts file?


Thanks!
Jenny
 
Hey,

You can use SSI if your hosts webserver is ASP or JSP capable.(Active Server Page or Java Server Page). Most web hosts that I've seen have microsoft or IIS compatible servers which means simply that they support ASP and so you may use include directives in your pages put you really don't need to do that because there is a simple way to link files into your page without using SSI.

Use the HTML <LINK> tag. **This tag can only be used within the <HEAD> tag of the page but will suit your purposes.**

Example:
<LINK REL=stylesheet HREF=&quot;styles.css&quot; TYPE=&quot;text/css&quot;>

**Any HTML element with an SRC attribute will also work to link to external files**
 
Hi people!

OneStiffRod,

I'd be using the tag you posted to call images. I have a bunch of different images that make up my Websites Menu. Each image has its own function.

Now, I know this LINK REL code below is placed in the < head > tag, but will this tag work...

[tt]<LINK REL=stylesheet HREF=&quot;styles.css&quot; TYPE=&quot;text/css&quot;>[/tt]

...if some of my images on my Menu call code that is also in the < head > tag?

Thanks for the link vituz!

Hope to hear from you guys!
Jenny
 
Hi,

If I understand you correctly, you want to use common navigation menus made up of images with rollover effects on all your pages AND you don't want to have to edit all your pages when you make changes, right? If this is the case, here's what I would (and do) do (do do?) ;-)

1- put your script for rollover in a file with a js extension. do not put the script tags in that file.
2- in every page that needs the rollover script, call it in the head section with a <script type='text/javascript' src='./path/file.js'></script>
3- if you need to call other scripts, just add <script> tags to the head section (yes you can call more than one)
4- put all your html code that creates your navigation gizmos in plain text file with a .txt or .inc (or .asp if on an IIS server) extension.
5- insert the navigation gizmos on your pages where they should appear with <!-- #include file='./path/file.inc' --> tags

Remember that SSI are processed on the server, before the page is sent to the browser and that scripts included in the head section are downloaded on the visitor's machine and processed there. By putting the scripts in the head, they will be available when they are needed, since they will download before the page loads. Since the scripts files and the images are probably the same on every page (at least the navigation gismoz' images), they will only be downloaded once and thereafter be fetched from the cache.

This should make your site easier to modify since you will only have to edit your SSI and scripts.

The only time I put a script directly into the page itself, is when that page is the only one using that script.

I hope this is clear and helpful

Bye.
 
Hi yahve!

If I understand you correctly, you want to use common navigation menus made up of images with rollover effects on all your pages AND you don't want to have to edit all your pages when you make changes, right?

That’s exactly what I want to do!

1- put your script for rollover in a file with a js extension. do not put the script tags in that file.

Do I just insert the script alone? Do I add any tags (html, title, head, body)?
When you write, “do not put the script tags in that file” do you mean the script tags that call the rollover script?

2- in every page that needs the rollover script, call it in the head section with a
<script type='text/javascript' src='./path/file.js'></script>
3- if you need to call other scripts, just add <script> tags to the head section (yes you can call more than one)

If I need to call more than one script in the < head > then should I put all of my scripts in separate files or should I put them all in one file?

4- put all your html code that creates your navigation gizmos in plain text file with a .txt or .inc (or .asp if on an IIS server) extension.

What is an .inc file? My host said I can use .txt, .html or .shtml extensions within my SSI code.

5- insert the navigation gizmos on your pages where they should appear with <!-- #include file='./path/file.inc' --> tags

…The only time I put a script directly into the page itself, is when that page is the only one using that script.

Why can’t I just put the actual code in each of my pages < head > tags? Why do I need:
[tt]<script type='text/javascript' src='./path/file.js'></script>[/tt] ?

What are the advantages / disadvantages of doing this?

For .js extensions, does my host need to support jsp or asp? If so, which one?


Thanks,
Jenny
 
hi Jenny,

I cant help much with the SSI side of things as im new this method of doing stuff myself.

The xtrnl Javascript files i can..

Basically you can make a .js file with every script you use throughout your whole site within. There are no tags anywhere just the scripts (the stuff you would place inside a script block in your doc head). Then every page which uses a script from your 'toolkit' has a link as shown in the above posts.

Thats it you have all your scripts in one place and no need for script blocks in your documents at all.

Of course you can link to more than one .js file in a doc if it suits you to split them up and you can have a link to a .js file and normal script blocks as well. Its fairly versatile in that respect.

hope this helps

rob
 
I'm going to take a stab and say that unless your host has uploads of files ending with .inc restricted, you should be able to upload them to the server and call them from within your .shtml, .asp or .jsp file.

The server isn't going to care what type of files you have in the directories until it comes time to parse them, and as long as the scritping engine is cfg'd properly, there won't be a problem. It's not like a .cgi or .pl file. You don't have to control the rwx and chmod the whole mess. You don't have to worry about it being uploaded in binary vs ascii, etc.

I can't see any reason why .inc would be a problem.

Unless of course your host only allows uploads of certain file types, like I mentioned before.

The .inc extension regers to INCLUDE files that will be parsed when a page calls for it. &quot;It's easier to ask forgiveness than it is to get permission.&quot; - Rear Admiral Dr. Grace Hopper
 
Hi,

Do I just insert the script alone? Do I add any tags (html, title, head, body)?
When you write, “do not put the script tags in that file” do you mean the script tags that call the rollover script?

The .js external file should only contain the script itself, no HTML (of course, your script might write out HTML with document.write statements. So do not include any HTML tags in your external .js file.


If I need to call more than one script in the < head > then should I put all of my scripts in separate files or should I put them all in one file?

Bingo! What you should do is put all of your js functions in a single file; this will create a library of functions. Then, you can call any of those function from any HTML page which refer to that external .js file in its head section, and when you need to modify any script, you just modify this one .js file!


What is an .inc file? My host said I can use .txt, .html or .shtml extensions within my SSI code.

On most servers, you can use the extension you want, or no extension at all! try it. I've tried no extension, .verylongextension files, .asp, and much more. The .txt, .html, .shtml extensions are just more usual. If you use .inc extension, it makes it easier to maintain your site since you will know right away that files with the .inc extension are includes. If you include an .shtml file, then this file will be processed by the server before being included, if it contains SSI directives, they will be processed. So you can include includes in your includes, and so on... :)


Why can’t I just put the actual code in each of my pages < head > tags?

You can put the code directly in each of your page... but it does not make sense if many pages are using the same code. By using an external .js file, you have only one file to maintain, you are sure that all HTML pages are using the same version of your script, and it will make your site faster since every HTML page will be smaller and the .js file will only be downloaded once by the browser.


For .js extensions, does my host need to support jsp or asp? If so, which one?

Working with .js file and including them in the head section of your HTML pages with <script type=&quot;text/javascript&quot; src=&quot;./path/file.js&quot;></script> does not require anything special on the server. The <script> tag will tell the browser to fetch the .js file like the <img alt=&quot;description&quot; src=&quot;./path/image.file&quot; /> tag tells it to fetch the image. It's really an include like SSI and <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;./path/file.css&quot; />


Bye.


 
Hi everyone!

>>For .js extensions, does my host need to support jsp or asp? If so, which one?

>Working with .js file and including them in the head section of your HTML pages with <script type=&quot;text/javascript&quot; src=&quot;./path/file.js&quot;></script> does not require anything special on the server.


I can’t my get my external .js script to work.

I used your example…

[tt]<script type=&quot;text/javascript&quot; src=&quot;./path/file.js&quot;></script>[/tt]

…but the javascript within my page still isn’t working. I have an SSI file that holds code that requires javascript from this external .js file.



Here’s the url that holds my .js file that isn’t working:

Note: After you rollover the cupid pic a snowflake is suppose to appear, but doesn’t (javascript).
(if you view the source then you’ll see my code in the < head > tag)




Here’s what my external javascript file looks like (named: javas.js in my /



Maybe it’s a problem with the path to my javascript file?

My external javascript file (javas.js) is located in my www directory.

Here’s the code I’m using to call my javas.js file:

[tt]<script type='text/javascript' src='./javas.js'></script>[/tt]



Is

[tt]type='text/javascript'[/tt]

correct?


Is

[tt]src='./javas.js'[/tt]

right? (I also tried just src=’javas.js”)



Thanks so much!
Jenny
 
Hi Jenny,

First, I checked out your stuff with both NetSh4.76 and IE5.5, and both reported the same error. Guess what, your error is on line 1 of javas.js! so your <script type='text/javascript' src='./javas.js'></script> tag is doing its job. Furthermore, since I could get your javas.js file from my cache, it means that it was downloaded. BTW, the syntaxe I've shown you is the correct one according to HTML 4.01 (the language attribute is deprecated).

Here is the output from NS console:


JavaScript Error:
line 1:

syntax error.

<script language=&quot;JavaScript&quot;>

^


Notice the ^ on the last line; that is where the error is occuring. So both NS and IE are reporting an error on the first character of the first line.

Next I look at the source of both your HTML page and your javas.js files. The error is very simple. You have included a <script> tag in your javas.js file. This tag should not be in the external js file since it already appears in the HTML page that calls it.

That's it. Everything is fine except for that <script> tag in the javas.js file.

Bye.
 
Hi!

Well, I fixed the [tt]<script>[/tt] problem, but I’m still unsuccessful with my testing.

Here’s what my adjusted [tt]javas.js[/tt] script looks like:


Here’s the url to my page.

- If you view the source of the page above you’ll notice that nothing comes in between my < javascript > tags within the < head >.
- If you rollover the cupid then a snowflake should appear to it’s left. However, this isn’t happening.


I don’t know what I can be doing wrong?
I’m uploading all of my files in the www directory. I believe that’s right?

====================

Here’s a couple things that you might need to know:

- The status bar on the bottom of my page displays: [tt]Error on Page[/tt]
- The .txt docs my SSI calls have [tt]< div > < /div >[/tt] tags inside of them. Here’s the code of the document my SSI calls on:


I’ll talk…er…I mean write with ya later! Thanks so much.
Jenny
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top