SitePoint Sponsor

User Tag List

Results 1 to 17 of 17

Hybrid View

  1. #1
    There can be only One.... joelwills's Avatar
    Join Date
    Jul 2000
    Location
    England
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi all,

    This is similar to the previous thread. I am trying to use an SSinclude to insert my menu information (not the .js file) in the head section. Again, this is so I don't have to update every page.

    However I get an error at the body tag, where I need to do
    OnLoad="init()"

    If I copy and paste the contents of the include into the html it works fine. Theoretically, this is all that the SSI is doing and so it should work.

    Does anybody know what I'm doing wrong? Thanks in advance!
    Life Goggles - The Entertaining Environment Blog
    http://www.lifegoggles.com

  2. #2
    SitePoint Addict SLeon's Avatar
    Join Date
    Sep 2000
    Location
    Northern California
    Posts
    222
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have done this exact thing that you are trying to do with no problem at all. You do have to put <body onload="init()"> into every page using the menu, do you have that? And the SSI for the menu is included inside the head tag? Can you give more details about exactly what you're doing and what might be causing it?
    InformationSavant - developing intelligent web business
    StrangePegs.com - collectible cards, games, toys, comics

  3. #3
    There can be only One.... joelwills's Avatar
    Join Date
    Jul 2000
    Location
    England
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help Sarah.

    Basically I am using a menu on my site www.joelwills.com which is from dynamic drive. The javascript controls are in a file called navcond.js which is called from the script. At the moment I have the script inside the <head> section. I have just cut this out (including the link to navcond.js) and put it into a text doc withthe extension .inc.
    I have then replaced it with the <!-- #include file="menu.inc"> statement and it no longer works.

    I am just testing it on one page at the moment. I hope that's clear, probably a simple mistake somewhere, but where!

    Thanks again for all your help
    Life Goggles - The Entertaining Environment Blog
    http://www.lifegoggles.com

  4. #4
    SitePoint Addict SLeon's Avatar
    Join Date
    Sep 2000
    Location
    Northern California
    Posts
    222
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using <!-- #include virtual="menu.inc"> instead. I have used that exact same script in that exact same way, but with the virtual include. Works for me. The only other difference that I can see is that you're using a .inc extension for the name of the file you want to include, while I used .html.
    InformationSavant - developing intelligent web business
    StrangePegs.com - collectible cards, games, toys, comics

  5. #5
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    a few things to check

    1) Upper/lower case. Are you using the right filename?

    2) Are you referring to the right file?

    3) Is the path to the included file correct?

    4) SLeon's answer is probably the right one though.

    It should be <!--#include virtual="path/to/file.inc" -->

    Make sure that there is NO space between the # and the word include.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  6. #6
    There can be only One.... joelwills's Avatar
    Join Date
    Jul 2000
    Location
    England
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks (to both of you!) - that works now!!

    Last edited by joelwills; May 1, 2001 at 11:57.
    Life Goggles - The Entertaining Environment Blog
    http://www.lifegoggles.com

  7. #7
    There can be only One.... joelwills's Avatar
    Join Date
    Jul 2000
    Location
    England
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HI - if you're still subscibed to this thread, maybe you can help with the next bit!

    I am trying to use the same menu.html for all my pages, such as those within other directories. How do I write the include to look at the menu.html which is on the root?

    <!--#include file="../menu.html"--> doesn't work, and neither does using virtual. Any ideas???

    Thanks again!
    Life Goggles - The Entertaining Environment Blog
    http://www.lifegoggles.com

  8. #8
    SitePoint Addict SLeon's Avatar
    Join Date
    Sep 2000
    Location
    Northern California
    Posts
    222
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK. I'm just going to ask a couple of stupid questions, to make sure that something hasn't been totally overlooked.

    Is the file that you're doing the include file from named with the .shtml extension?

    Is SSI enabled on your server?

    I'm really stumped as to what could be making this not work for you. You can use SSI to include a file that's anywhere on your server. I admit that the difference between "file" and "virtual" confuses me, so I tend to just use "virtual" and it works.

    Also make sure that your syntax on the include command is exactly right, being careful of spaces and all that as creole mentioned earlier. Should be <!--#include virtual="../menu.html" -->
    InformationSavant - developing intelligent web business
    StrangePegs.com - collectible cards, games, toys, comics

  9. #9
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    a few things:

    1) You may want to try renaming the included file to something ofther than .html. I seem to recall having difficulty including HTML files. Try .txt or .ssi.

    2) Keep in mind that unless your shtml files are all on the same directory you can't use the identical include on every one of them.

    for example:

    /root/includes/file.ssi (this is the file to be included)

    /index.html (the index file of the site)
    <!--#include virtual="includes/file.ssi" -->

    /root/aboutus/index.html
    <!--#include virtual="../includes/file.ssi" -->

    /root/products/index.html
    <!--#include virtual="../includes/file.ssi" -->

    /root/products/widget/index.html
    <!--#include virtual="../../includes/file.ssi" -->

    OK, this is a mock structure. If you had your site set up like this, then you would have to use 3 different include calls as listed.

    Tell you what? Try these out, then if they don't work, give us the error message and I'll figure it out from there.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  10. #10
    There can be only One.... joelwills's Avatar
    Join Date
    Jul 2000
    Location
    England
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks again.

    I have done everything both of you have suggested and have solved it finally!

    No idea what was causing my problem, but when I did it by hand (I was using Dreamweaver) it now works. Strange, but some things are best done in Notepad.
    Also using 'virtual' doesn't work for me (I get an SSI error), but using 'file' does! I don't understand the difference either.

    FYI I also needed the navcond.js file in every directory, but I already had that, so that wasn't causing the problem.

    Thanks once again to both of you for your time, you've really helped me out
    Life Goggles - The Entertaining Environment Blog
    http://www.lifegoggles.com

  11. #11
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hehe...

    Joel, this page looks like it might be the answer to your file vs virtual problem.

    http://www.stars.com/Authoring/SSI/Intro/include.html

    An excerpt from this page:
    file gives a pathname relative to the current directory. ../ cannot be used in this pathname, nor can absolute paths be used.

    and

    virtual gives a virtual path to a document on the server.

    So, basically, if you are trying to use file to go UP a directory it won't work. File starts from the current directory and ONLY allows you to go deeper.

    Virtual, on the other hand, starts from the servers root meaning that you could go all the way to / and go down into another directory.

    See if that works.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  12. #12
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Milton Keynes, UK
    Posts
    1,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is server type dependent somewhat, as MS IIS does support the use of :

    <!--#include file="../includes/file.ssi" -->

    If joel is using MS PWS for testing then that may explain some of his problems, as PWS doesn't support virtual includes.

  13. #13
    There can be only One.... joelwills's Avatar
    Join Date
    Jul 2000
    Location
    England
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still not working!

    I am using MS PWS which may be a problem when testing. SSI works fine either using file or virtual if the .shtml files are under the main public_html directory, however, not when located in any other directory. Let me give you an example. I have the structure:

    public_html -
    ------------ includes
    -------------------- include1.html
    ------------ directory
    -------------------- example.shtml

    I cannot seem to call include1.html from example.shtml

    I am trying to use <!-- #include virtual="/includes/include1.html"--> as suggested on the page creole gave me the link to. According to that page:
    Using this method, you can create all of your HTML pages with the same include, place them in various directories and sub-directories, and the server will be able to find your include; no error messages.
    I don't get error messages (unless I'm trying to include the javascript menu), but no information either. Does anyone know where I'm going wrong? It's driving me crazy. SSI definitley work on my server, so that's not the problem!
    Life Goggles - The Entertaining Environment Blog
    http://www.lifegoggles.com

  14. #14
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so, when your included files don't appear you don't get a "directive not processed error?" It would appear right in the HTML itself, not as a popup.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  15. #15
    There can be only One.... joelwills's Avatar
    Join Date
    Jul 2000
    Location
    England
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's right, I just get nothing. I get an error message using PWS, but as Shane mentions, that must be due to PWS not supporting virtual includes.

    Good hey?
    Life Goggles - The Entertaining Environment Blog
    http://www.lifegoggles.com

  16. #16
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Location
    D¨n ╔ideann, Alba
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Get rid of the space between the "<!--" and the "#". This causes problems on Unix servers.


  17. #17
    There can be only One.... joelwills's Avatar
    Join Date
    Jul 2000
    Location
    England
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks - that's solved it (finally )

    Thanks to you all!!
    Life Goggles - The Entertaining Environment Blog
    http://www.lifegoggles.com


Bookmarks

Posting Permissions

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