HTP

htp on-line reference : Including

Table of Contents
  Introduction
  License
  Tutorial
    Macros
  > Including
    Templates
    Files
    Metatags
  Usage
  HTP Tags
  History
  Wish list
  Bugs

How to put common parts in different files

When you have a web site consisting of several pages, you may notice that you often need to add the same html code to all pages. With htp you can put common code in extra files and include them in all pages. Here is an example.

 1. <[ref]set title="htp file include example">
 2. <[ref]file include="header.hti">
 3. <h2>Here is the content</h2>
 4. <p>
 5. As you can see the file contains almost only the contents.
 6. </p>
 7. <[ref]file include="footer.hti">

In line 2 the [ref]file tag is used to include a different file. When this tag is processed, htp will read and process the file header.hti (see below) and after it is finished it continues after the tag. The included file contains the usual html header and the navigation bar. All macros defined before the file include tag are also visible in the included file. So the macro title defined in the first line is used in the header to produce the title of the page:

 1. <html>
 2.  <head><title><[ref]use title></title></head>
 3.  <body>
 4.   <table>
 5.    <tr><td>
 6.      Navigation bar<br>
 7.      <a href="main.html">Main</a><br>
 8.      <a href="example.html">Example</a><br>
 9.    </td>
10.    <td>

Similarly, in the last line of our example the file footer.hti is included, which contains the common copyright information and the necessary closing tags:

 1.    </td></tr>
 2.   </table>
 3.   <hr>
 4.   Copyright by <a href="mailto:webmaster@domain.com">Joe Doe</a>.<br>
 5.   last updated <[ref]file date>
 6.  </body>
 7. </html>

In the next section, we will show you a similar mechanism, the template.

  page source
  htp project
  htp homepage
hosted by
SourceForge.net
HTML coding Powered by htp
htp on-line reference / http://htp.sourceforge.net/ref/
Authors: Jim Nelson, Jochen Hoenicke, Michael Möller.
Maintainers: Jochen Hoenicke.

Copyright © 1995-96 Jim Nelson.
Copyright © 2001-2003 Jochen Hoenicke.
Permission to reproduce and distribute this hypertext document granted according to terms described in the License section.

last updated Thu Apr 17, 2014