HTP

Source code: ref/include.htp

Table of Contents
  htp.def
  macros.def
  htp.htt

<BLOCK body>

<H2>How to put common parts in different files</H2>

<p>
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 <a href="tut/tut2.htp">example</a>.
</p>

<htpcode file="tut/tut2.htp" linenr>
<set title="htp file include example">
<file include="header.hti">
<h2>Here is the content</h2>
<p>
As you can see the file contains almost only the contents.
</p>
<file include="footer.hti">
</htpcode>

In line 2 the <manlink
href="file.html">
<code>file</code></file></manlink> tag is used to
include a different file.  When this tag is processed, htp will read
and process the file <a href="tut/header.hti">header.hti</a> (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 <code>file include</code> tag are also
visible in the included file.  So the macro <code>title</code> defined
in the first line is used in the header to produce the title of the
page:

<htpcode file="tut/header.hti" linenr>
<html>
 <head><title><use title></title></head>
 <body>
  <table>
   <tr><td>
     Navigation bar<br>
     <a href="main.html">Main</a><br>
     <a href="example.html">Example</a><br>
   </td>
   <td>
</htpcode>

Similarly, in the last line of our example the file <a
href="tut/footer.hti">
footer.hti</a> is included, which contains the
common copyright information and the necessary closing tags:

<htpcode file="tut/footer.hti" linenr>
   </td></tr>
  </table>
  <hr>
  Copyright by <a href="mailto:webmaster@domain.com">Joe Doe</a>.<br>
  last updated <file date>
 </body>
</html>
</htpcode>

In the <a href="template.html">next section</a>, we will show you a
similar mechanism, the template.

</BLOCK>

  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 Tue Feb 22, 2011