SSI: path to file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Frances Del Rio

    SSI: path to file

    I'm doing a website in which in all html files I have an SSI directive,
    thus:

    <!--#include file="nav.html"-->

    but if I call same file from an html file in a sub-dir in webiste, thus:

    <!--#include file="../nav.html"-->

    it won't work, I get this error:

    [an error occurred while processing this directive]

    would appreciate any suggestions.. thank you..

    Frances

  • Adrienne

    #2
    Re: SSI: path to file

    Gazing into my crystal ball I observed Frances Del Rio <fdr58@yahoo.co m>
    writing in news:39cek7F60i 0ucU1@individua l.net:
    [color=blue]
    > I'm doing a website in which in all html files I have an SSI directive,
    > thus:
    >
    > <!--#include file="nav.html"-->
    >
    > but if I call same file from an html file in a sub-dir in webiste, thus:
    >
    > <!--#include file="../nav.html"-->
    >
    > it won't work, I get this error:
    >
    > [an error occurred while processing this directive]
    >
    > would appreciate any suggestions.. thank you..
    >
    > Frances
    >
    >[/color]

    <!--#include virtual="../nav.html"-->

    --
    Adrienne Boswell
    Arbpen Consulting will help you harness valuable insights and translate them into tangible results by merging data and strategy.

    Please respond to the group so others can share

    Comment

    • Frances Del Rio

      #3
      Re: SSI: path to file

      Adrienne wrote:
      [color=blue]
      > Gazing into my crystal ball I observed Frances Del Rio <fdr58@yahoo.co m>
      > writing in news:39cek7F60i 0ucU1@individua l.net:
      >
      >[color=green]
      >>I'm doing a website in which in all html files I have an SSI directive,
      >>thus:
      >>
      >> <!--#include file="nav.html"-->
      >>
      >>but if I call same file from an html file in a sub-dir in webiste, thus:
      >>
      >> <!--#include file="../nav.html"-->
      >>
      >>it won't work, I get this error:
      >>
      >> [an error occurred while processing this directive]
      >>
      >>would appreciate any suggestions.. thank you..
      >>
      >>Frances
      >>
      >>[/color]
      >
      >
      > <!--#include virtual="../nav.html"-->[/color]

      oh my gosh -- I had no idea.. so any time you call a file w/an SSI
      directive that's not in same dir as file where directive is you have to
      use 'virtual' instead of 'file'..... interesting.... . thank you very
      much for prompt response... Frances


      [color=blue]
      >[/color]

      Comment

      • Frances Del Rio

        #4
        Re: SSI: path to file



        Frances Del Rio wrote:
        [color=blue]
        > Adrienne wrote:
        >[color=green]
        >> Gazing into my crystal ball I observed Frances Del Rio
        >> <fdr58@yahoo.co m> writing in news:39cek7F60i 0ucU1@individua l.net:
        >>
        >>[color=darkred]
        >>> I'm doing a website in which in all html files I have an SSI
        >>> directive, thus:
        >>>
        >>> <!--#include file="nav.html"-->
        >>>
        >>> but if I call same file from an html file in a sub-dir in webiste, thus:
        >>>
        >>> <!--#include file="../nav.html"-->
        >>>
        >>> it won't work, I get this error:
        >>>
        >>> [an error occurred while processing this directive]
        >>>
        >>> would appreciate any suggestions.. thank you..
        >>>
        >>> Frances
        >>>
        >>>[/color]
        >>
        >>
        >> <!--#include virtual="../nav.html"-->[/color]
        >
        >
        > oh my gosh -- I had no idea.. so any time you call a file w/an SSI
        > directive that's not in same dir as file where directive is you have to
        > use 'virtual' instead of 'file'..... interesting.... . thank you very
        > much for prompt response... Frances[/color]

        actually....... it doesn't quite work.. images in file being called
        w/SSI directive ('images/img.gif') don't show up.. in this file for
        images to show up I would have to put '../images/img.gif' this is so
        weird.. I think I will have to do a separate file for this dir after
        all... at any rate thanks again.. Frances



        Comment

        • Lars Eighner

          #5
          Re: SSI: path to file

          In our last episode,
          <39cgs1F611nfaU 2@individual.ne t>,
          the lovely and talented Frances Del Rio
          broadcast on comp.infosystem s.www.authoring.html:

          [color=blue]
          > actually....... it doesn't quite work.. images in file being called
          > w/SSI directive ('images/img.gif') don't show up..[/color]

          What in the world would make you think that you can use SSI to
          insert a image file into a text file (and html is just a kind of
          text file). Have you ever opened an image file in a text
          editor? Looks like garbage doesn't it? (If you are a MicroSoft
          user, you'll just have to trust me on that.) I'm willing to bet
          you don't want that string of nonsense characters in your web
          page. No, you want your image to show up as a *picture* in
          graphical browsers, don't you? Well, html has an element for
          that. It is IMG. Look into it.
          [color=blue]
          > in this file for
          > images to show up I would have to put '../images/img.gif' this is so
          > weird.. I think I will have to do a separate file for this dir after
          > all... at any rate thanks again.. Frances[/color]

          No, you need to learn some basics of html, and about how various
          kinds of data are stored in computer files.

          You can put the text for the IMG element in a text file and use
          SSI to include the text file. You might want to do this, for
          example, if you had a snip of markup that was for a menu or a
          logo and had IMG and text elements. You might put the text for
          that snip of markup in a text file and use SSI to put the menu
          or the logo on many pages. Then if you ever wanted to change
          the menu or the logo, you would only have to change the snip of
          markup. You would not have to edit every page that included it.
          This is the primary use for includes: for markup that will be
          included on many pages. If you are building your beginner's
          pages by using a bunch of includes, each of which is only used
          once, you are on the wrong track.


          --
          Lars Eighner eighner@io.com http://www.io.com/~eighner/
          It's important for us to explain to our nation that life is important. It's
          not only life of babies, but it's life of children living in, you know, the
          dark dungeons of the Internet.--G.W. Bush, Arlington Heights, Ill.,10/24/00

          Comment

          • Frances Del Rio

            #6
            Re: SSI: path to file

            Lars Eighner wrote:[color=blue]
            > In our last episode,
            > <39cgs1F611nfaU 2@individual.ne t>,
            > the lovely and talented Frances Del Rio
            > broadcast on comp.infosystem s.www.authoring.html:
            >
            >
            >[color=green]
            >>actually..... .. it doesn't quite work.. images in file being called
            >>w/SSI directive ('images/img.gif') don't show up..[/color]
            >
            >
            > What in the world would make you think that you can use SSI to
            > insert a image file into a text file (and html is just a kind of
            > text file). Have you ever opened an image file in a text
            > editor? Looks like garbage doesn't it? (If you are a MicroSoft
            > user, you'll just have to trust me on that.) I'm willing to bet
            > you don't want that string of nonsense characters in your web
            > page. No, you want your image to show up as a *picture* in
            > graphical browsers, don't you? Well, html has an element for
            > that. It is IMG. Look into it.
            >
            >[color=green]
            >>in this file for
            >>images to show up I would have to put '../images/img.gif' this is so
            >>weird.. I think I will have to do a separate file for this dir after
            >>all... at any rate thanks again.. Frances[/color]
            >
            >
            > No, you need to learn some basics of html, and about how various
            > kinds of data are stored in computer files.[/color]

            ok, I was misunderstood, I'm afraid I didn't explain myself too clearly
            (I do know HTML very well, have been coding for about 10 years now, am a
            strict hand-coder, I hate WYSIWYGs..)

            file I need to call in SSI directive is called nav.html -- THIS is what
            I call in SSI directive, obviously, not images.. I was talking about
            images called INSIDE that file, which is a conventional HTML file..

            so: nav.html is in root.. in a sub-dir I call it thus:

            <!--#include virtual="../nav.html"-->

            now INSIDE nav.html I have: <img src="images/button/gif"> THIS image
            does not appear IF and only IF I call file in a SSI directive from a
            sub-directory, they appear fine if file is called from a file in root
            (i.e., same dir where file called in SSI directive is..) I hope this is
            clearer now.. thank you very much........ Frances









            Comment

            • Mark Parnell

              #7
              Re: SSI: path to file

              Previously in comp.infosystem s.www.authoring.html, Frances Del Rio
              <fdr58@yahoo.co m> said:
              [color=blue]
              > <!--#include virtual="../nav.html"-->
              >
              > now INSIDE nav.html I have: <img src="images/button/gif"> THIS image
              > does not appear IF and only IF I call file in a SSI directive from a
              > sub-directory, they appear fine if file is called from a file in root
              > (i.e., same dir where file called in SSI directive is..)[/color]

              You would need to change the image to an absolute URI, e.g. <img
              src="/images/button/gif">. The browser only sees the finished product of
              the page, once the includes are, um, included. :-) So if you include
              nav.html in a file in a subdirectory, at the moment it is looking for an
              "images" directory *in that subdirectory*.

              --
              Mark Parnell

              Comment

              • Jim Moe

                #8
                Re: SSI: path to file

                Frances Del Rio wrote:[color=blue]
                >
                > actually....... it doesn't quite work.. images in file being called
                > w/SSI directive ('images/img.gif') don't show up.. in this file for
                > images to show up I would have to put '../images/img.gif' this is so
                > weird.. I think I will have to do a separate file for this dir after
                > all...
                >[/color]
                You have just stumbled on a reason why it is a good idea have the local
                directory structure match the site's directory. It makes maintenance a
                *lot* easier.

                --
                jmm dash list (at) sohnen-moe (dot) com
                (Remove .AXSPAMGN for email)

                Comment

                • Lars Eighner

                  #9
                  Re: SSI: path to file

                  In our last episode, <39cmtcF5tb42pU 1@individual.ne t>, the
                  lovely and talented Frances Del Rio broadcast on
                  comp.infosystem s.www.authoring.html:
                  [color=blue]
                  > file I need to call in SSI directive is called nav.html -- THIS is what
                  > I call in SSI directive, obviously, not images.. I was talking about
                  > images called INSIDE that file, which is a conventional HTML file..[/color]
                  [color=blue]
                  > so: nav.html is in root.. in a sub-dir I call it thus:[/color]
                  [color=blue]
                  > <!--#include virtual="../nav.html"-->[/color]
                  [color=blue]
                  > now INSIDE nav.html I have: <img src="images/button/gif"> THIS image
                  > does not appear IF and only IF I call file in a SSI directive from a
                  > sub-directory, they appear fine if file is called from a file in root
                  > (i.e., same dir where file called in SSI directive is..) I hope this is
                  > clearer now.. thank you very much........ Frances[/color]

                  OK. When you use SSIs, the page as received by a browser is
                  seamless - as if you had actually cut-and-pasted the text from
                  the include into your document. The browser doesn't know it is
                  reading an include. So if you have a *relative* path in the
                  include, the browser can only interpret it as *relative* to the
                  document it has - the browser doesn't know there is an include,
                  much less where the include came from.

                  When the browser comes to src="images/button.gif" it is going
                  to ask for "button.gif " from the "images" subdirectory of
                  the same directory as the current document. This is because
                  relative paths are figured as being relative to the current
                  document.

                  You have these files:

                  /nav.html (the include, which has src="images/button.gif")
                  /images/button.gif
                  /somedir/mydoc.html (the document with the SSI
                  src="images/button.gif")

                  When you browse mydoc.html, the browser then looks for:

                  /somedir/images/button.gif (which of course is not what you
                  want, but is exactly the right behavior from the browser).

                  To fix this, you can:

                  1) use absolute paths in the include (src="/images/button.gif").
                  That leading / is your document root. There are many ways that
                  hosts are configured, so the document root might not be what you
                  consider the root of your site, or in other words, it might have
                  to be src="/myusername/images/button.gif"
                  or src="/~myusername/images/button.gif" or
                  src="/somealias/images/button.gif". You'll just have to
                  investigate how your server is configured yourself, or
                  experiment a little.

                  2) use complete URIs (i.e. src="http://www. etc.) This, of
                  course, will make your documents very non-portable and will make
                  local (i.e. offline) testing pretty much impossible.

                  3) have different includes for documents in different
                  directories. For some kinds of includes, this makes some sense.

                  4) scrap SSI and use a preprocessor to build pages.
                  Preprocessors are much more powerful than SSI, anyway.

                  --
                  Lars Eighner eighner@io.com http://www.io.com/~eighner/
                  "We have no opinion on your Arab - Arab conflicts, such as your dispute with
                  Kuwait." -- Bush's Ambassador April Glaspie, giving Saddam Hussein
                  the greenlight to invade Kuwait.

                  Comment

                  • Frances Del Rio

                    #10
                    Re: SSI: path to file

                    Lars Eighner wrote:
                    [color=blue]
                    > In our last episode, <39cmtcF5tb42pU 1@individual.ne t>, the
                    > lovely and talented Frances Del Rio broadcast on
                    > comp.infosystem s.www.authoring.html:
                    >[color=green]
                    >>file I need to call in SSI directive is called nav.html -- THIS is what
                    >>I call in SSI directive, obviously, not images.. I was talking about
                    >>images called INSIDE that file, which is a conventional HTML file..[/color]
                    >[color=green]
                    >>so: nav.html is in root.. in a sub-dir I call it thus:[/color]
                    >[color=green]
                    >> <!--#include virtual="../nav.html"-->[/color]
                    >[color=green]
                    >>now INSIDE nav.html I have: <img src="images/button/gif"> THIS image
                    >>does not appear IF and only IF I call file in a SSI directive from a
                    >>sub-directory, they appear fine if file is called from a file in root
                    >>(i.e., same dir where file called in SSI directive is..) I hope this is
                    >>clearer now.. thank you very much........ Frances[/color]
                    >
                    >
                    > OK. When you use SSIs, the page as received by a browser is
                    > seamless - as if you had actually cut-and-pasted the text from
                    > the include into your document. The browser doesn't know it is
                    > reading an include. So if you have a *relative* path in the
                    > include, the browser can only interpret it as *relative* to the
                    > document it has - the browser doesn't know there is an include,
                    > much less where the include came from.
                    >
                    > When the browser comes to src="images/button.gif" it is going
                    > to ask for "button.gif " from the "images" subdirectory of
                    > the same directory as the current document. This is because
                    > relative paths are figured as being relative to the current
                    > document.
                    >
                    > You have these files:
                    >
                    > /nav.html (the include, which has src="images/button.gif")
                    > /images/button.gif
                    > /somedir/mydoc.html (the document with the SSI
                    > src="images/button.gif")
                    >
                    > When you browse mydoc.html, the browser then looks for:
                    >
                    > /somedir/images/button.gif (which of course is not what you
                    > want, but is exactly the right behavior from the browser).
                    >
                    > To fix this, you can:
                    >
                    > 1) use absolute paths in the include (src="/images/button.gif").
                    > That leading / is your document root. There are many ways that
                    > hosts are configured, so the document root might not be what you
                    > consider the root of your site, or in other words, it might have
                    > to be src="/myusername/images/button.gif"
                    > or src="/~myusername/images/button.gif" or
                    > src="/somealias/images/button.gif". You'll just have to
                    > investigate how your server is configured yourself, or
                    > experiment a little.
                    >
                    > 2) use complete URIs (i.e. src="http://www. etc.) This, of
                    > course, will make your documents very non-portable and will make
                    > local (i.e. offline) testing pretty much impossible.
                    >
                    > 3) have different includes for documents in different
                    > directories. For some kinds of includes, this makes some sense.
                    >
                    > 4) scrap SSI and use a preprocessor to build pages.
                    > Preprocessors are much more powerful than SSI, anyway.[/color]

                    ok, I see what issue is, thank you very much....

                    (what is a preprocessor?)

                    Frances










                    Comment

                    • Lars Eighner

                      #11
                      Re: SSI: path to file

                      In our last episode,
                      <39dth2F5un24nU 1@individual.ne t>,
                      the lovely and talented Frances Del Rio
                      broadcast on comp.infosystem s.www.authoring.html:
                      [color=blue]
                      > (what is a preprocessor?)[/color]

                      A preprocessor is a program which takes a source document
                      (usually some kind of text - remember html is a kind of text
                      document) using includes, variables, conditional statements, and
                      function calls and produces an output document suitable for a
                      particular purpose (in this case, an html document that can be
                      served as-is). Many preprocessors were developed to make it
                      easier to write computer programs - but can be used for many
                      kinds of text. Some have been developed especially for the
                      needs of html.

                      Here, for example, is the template for one of my pages:

                      #include header.chml
                      #include help.rbar
                      <DIV>%getimage( banner,&pagereg )</DIV>\
                      <br class="clearl">
                      #include index.lbar
                      #include help.body
                      #include footer.chml

                      Well, of course, you know what includes are, and you could do
                      most of this SSI. However, there is a function in the DIV
                      which will insert the markup for my banner image - and this
                      function will get the path right because in header.chml I
                      have set a variable to say which directory this document is
                      going to be in. The function will also look up the photo credit
                      for the banner image and write snips of markup that will be
                      included in the footer here and in my copyright page to ensure
                      the photo credit gets enter both places.

                      Here is a snip from help.rbar:

                      <li>%getlink(%< location>,links-tour,%'Links tour.')</li>
                      <li>%getlink(%< location>,works-tour,%'My works here.')</li>
                      <li>%getlink(%< location>,write rndx,%'Writers\ ' resources.')</li>
                      <li>%getlink(%< location>,cours estart,%'Online Writing Course.')</li>

                      These are functions calls which will produce links to various
                      of my other pages in various directories. Again these links
                      will always be right, because I have set the variable for the
                      location of this page back in header.chml.

                      here is what those line produce here:

                      <li><a href="links/links_index.htm l#tour" title=
                      "Links Navigation Page: Guided Tour" type="text/html" charset=
                      "ISO-8859-1" lang="en-us">Links tour.</a></li>

                      <li><a href="lars_work s_here.html#tou r" title=
                      "Lars Eighner's Works at This Site: Guided Tour" type="text/html"
                      charset="ISO-8859-1" lang="en-us">My works here.</a></li>

                      <li><a href="wrtrmain. html" title=
                      "Lars Eighner's Writers' Main Index" type="text/html" charset=
                      "ISO-8859-1" lang="en-us">Writers' resources.</a></li>

                      <li><a href="writing_c ourse/index.html" title=
                      "Lars Eighner's Online Writing Course" type="text/html" charset=
                      "ISO-8859-1" lang="en-us">Online Writing Course.</a></li>

                      Perhaps you have seen the kind of menu in which when the current
                      page is a menu item, that item is grayed or omitted (so you
                      won't/can't select a link to the current page). This sort of
                      thing is very easily done with a preprocess. The source
                      document has a variable that says what page it is, so the
                      preprocessor function doesn't put A HREF around references to
                      that page. You can do that by hand, but that entails changing
                      the menu by hand on each page that is a menu item.


                      This is for a preprocessor called chpp. It is something of a
                      pain to work with - although, of course, way ahead of generating
                      the markup by hand. As I have said, there are may preprocessors
                      available. Almost every platform will have a preprocessor for
                      the C programming language. It isn't ideal, but you can use it
                      for html. I use chpp to generate my stylesheets, even though
                      chpp is supposedly especially meant for html. Many
                      wordprocessors and editors have some (possibly crude)
                      preprocessor functions (which are typically used for things like
                      form letters or other documents with a lot of boilerplate and a
                      few variables).




                      --
                      Lars Eighner eighner@io.com http://www.io.com/~eighner/
                      Dynamic linking error: Your mistake is now everywhere.

                      Comment

                      Working...