Placing Common HTML Code In A "Common" File

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sherry Littletree

    Placing Common HTML Code In A "Common" File

    Hi All

    I am working on a site that has a large amount of common html on all its web
    pages.
    I am looking for a way to place this in a single file so, if changes are
    made, I can change this single file and do not have to change each and every
    page.
    I have the Java scripting in a common .Js file but have not been able to
    find a way to do this with my html content.

    Anyone ever do this and if so how?
    An example would be Great!

    Thanks in advance.

    Hugs
    Sherry


  • VK

    #2
    Re: Placing Common HTML Code In A "Common&qu ot; File


    erver+Side+Incl udes


    Comment

    • Stephen

      #3
      Re: Placing Common HTML Code In A "Common&qu ot; File

      Sherry Littletree wrote:
      [color=blue]
      > Hi All
      >
      > I am working on a site that has a large amount of common html on all its web
      > pages.
      > I am looking for a way to place this in a single file so, if changes are
      > made, I can change this single file and do not have to change each and every
      > page.
      > I have the Java scripting in a common .Js file but have not been able to
      > find a way to do this with my html content.
      >[/color]

      (NB: properly, "javascripting" , not "Java scripting", since Java and
      javascript are completely separate languages.)
      [color=blue]
      > Anyone ever do this and if so how?
      > An example would be Great!
      >[/color]

      There are two things that come to my mind right away:

      1. Create a javascript file that will (contain functions that)
      document.write the common HTML
      2. Use Server-Side Includes (SSI) (I use this technique on my intranet)

      Each has advantages and disadvantages:

      For 1:
      Advantages:
      A. Requires no special server configuration
      B. Lets you deliver the common markup packaged as javascript (and since
      you're asking in a javascript group, I assume this is comfortable to you)

      Disadvantages:
      The material written by javascript will be completely unavailable to
      anyone whose browser has js unavailable for any reason (non-existent,
      disabled, etc). This seriously breaks your pages.

      For 2:
      Advantages:
      A. Common content can be placed in files that contain HTML that would
      otherwise be written into the main HTML file. Any such common HTML file
      is designated to be included by a Server-Side Includes directive such as:

      <!--#include file="location/file.ext" --> or
      <!--#include virtual="url/file.ext" -->

      Trivial example:

      <html>
      <head><title>Tr ivial SSI Example</title></head>
      <body>
      <!--#include file="PageHeade r.html" -->
      <br>
      My unique page content
      <br>
      <!--#include file="PageFoote r.html -->
      </body>
      </html>

      PageHeader.html :
      <h1>Page Header</h1>

      PageFooter.html :
      <p>Brought to you by SSI!</p>

      Output might be rendered as:

      Page Header

      My other page content

      Brought to you by SSI!


      B. No reliance on javascript or other client-side active scripting. All
      SSI processing takes place (obviously :-) ) at the server.

      Disadvantages:
      A. Server must be configured to support Server-Side Includes. Usually
      this also means that the main HTML file (i.e., any HTML file containing
      SSI directives) must be given a special extension such as ".shtml" (the
      customary one, usually read as "server-parsed" HTML).
      B. This requires more processing by the web server, which has to read
      the content of the file being served, looking for the SSI directives and
      following the indicated instructions.

      Google for "server-side includes" for additional info. There should be lots.

      Regards,

      Stephen



      Comment

      • David Dorward

        #4
        Re: Placing Common HTML Code In A &quot;Common&qu ot; File

        Sherry Littletree wrote:
        [color=blue]
        > I am working on a site that has a large amount of common html on all its
        > web pages.[/color]

        Generally if there is a _large_ amount, its caused by the use of too much
        presentational markup. Move your presentation to an external style sheet
        file instead.

        However, even that will leave some elements you may with to have in common
        on each page (such as navigation).
        [color=blue]
        > I am looking for a way to place this in a single file so, if changes are
        > made, I can change this single file and do not have to change each and
        > every page.[/color]



        --
        David Dorward http://dorward.me.uk/

        Comment

        • news frontiernet.net

          #5
          Re: Placing Common HTML Code In A &quot;Common&qu ot; File

          Here are two reasons why I cjhose NOT to use SSI as a method to do including
          of common modules;
          DRAWBACK #!: The use of SSI will make it neartly imposible to do simple
          WSYWIG trial and ewrror development work.
          DRAWBACK #2: the use of SSI requires the extension of the files to be .shtml
          or such. This makes other local authoring tools crap on you, like FrontPage
          does.

          I chose to use FrontPage as the method to do includes of commong dodules in
          a WSYWIG authoring environment on my loac PC where I could test and develop
          in a trial_and_error method.

          I suspect there are other tools out there besides FrontPage that will do
          this without forcing you to rename the extensions and without giving up
          local testing. But, I do not know what they are.

          "David Dorward" <dorward@yahoo. com> wrote in message
          news:bomc83$8fr $1$8302bc10@new s.demon.co.uk.. .[color=blue]
          > Sherry Littletree wrote:
          >[color=green]
          > > I am working on a site that has a large amount of common html on all its
          > > web pages.[/color]
          >
          > Generally if there is a _large_ amount, its caused by the use of too much
          > presentational markup. Move your presentation to an external style sheet
          > file instead.
          >
          > However, even that will leave some elements you may with to have in common
          > on each page (such as navigation).
          >[color=green]
          > > I am looking for a way to place this in a single file so, if changes are
          > > made, I can change this single file and do not have to change each and
          > > every page.[/color]
          >
          > http://www.allmyfaqs.com/faq.pl?Incl...ile_in_another
          >
          > --
          > David Dorward http://dorward.me.uk/[/color]


          Comment

          • Graham J

            #6
            Re: Placing Common HTML Code In A &quot;Common&qu ot; File

            > DRAWBACK #2: the use of SSI requires the extension of the files to
            be .shtml[color=blue]
            > or such.[/color]

            The use of .shtml is typically just a server default and where SSIs
            are the rule rather than the exception the server can usefully be
            directed to parse .html and .htm too. Of course you may not have this
            degree of access to the server configuration.

            Comment

            • David Dorward

              #7
              Re: Placing Common HTML Code In A &quot;Common&qu ot; File

              news frontiernet.net wrote:

              Maybe you (what a funny name you have BTW) should read:

              [color=blue]
              > Here are two reasons why I cjhose NOT to use SSI as a method to do
              > including of common modules;
              > DRAWBACK #!: The use of SSI will make it neartly imposible to do simple
              > WSYWIG trial and ewrror development work.[/color]

              WRONG!

              Leaving aside the non-existance of WYSIWYG editors for the web, and the
              general poor quality of those editor which claim to be WYSIWYG (but are
              really just graphical HTML/CSS generators) -

              * If you are doing trial and error development work, you can build your
              template and then rip it apart to use for SSI

              * A number of generators can emulate SSI during the design process
              [color=blue]
              > DRAWBACK #2: the use of SSI requires the extension of the files to be
              > .shtml or such.[/color]

              WRONG!

              See the second link in the section on SSI at the page:


              .... and of course the server could be configured to use whatever extension
              you want (if you don't want to use the XBitHack).

              --
              David Dorward http://dorward.me.uk/

              Comment

              • Warren Sarle

                #8
                Re: Placing Common HTML Code In A &quot;Common&qu ot; File


                In article <gFurb.6104$6c3 .838@newsread1. news.pas.earthl ink.net>,
                "Sherry Littletree" <encryted@encry ted.org> writes:[color=blue]
                >
                > I am working on a site that has a large amount of common html on
                > all its web pages. I am looking for a way to place this in a single
                > file so, if changes are made, I can change this single file and do
                > not have to change each and every page. I have the Java scripting
                > in a common .Js file but have not been able to find a way to do
                > this with my html content.[/color]

                PHP is easier to use than SSI and much more powerful. Any server-
                side approach is better than javascript because server-side
                processing will work even if the client disables active scripting/
                javascript.


                --

                Warren S. Sarle SAS Institute Inc. The opinions expressed here
                saswss@unx.sas. com SAS Campus Drive are mine and not necessarily
                (919) 677-8000 Cary, NC 27513, USA those of SAS Institute.

                Comment

                Working...