English Version

Other Sites:


Rolling out identical data

The content of the <head> section usually remains widely unaltered across all HTML files of a website. The vantage of keeping the constant part in a separate file is obvious. What we need to do it like this with UHTML is to create an <include> tag that inserts the content of one file called head-data in several html files. We suppose that we have an include directory in our document root where we keep our overlapping chunks of HTML. Our UHTML file could then look like this:

      <include file="/include/head-data">

The functionality of the <include> tag is an asset in many projects. Following the mentioned naming convention proposal the perl code is placed in a file named include.pm located in the subdirectory UHTML of the script directory. The file include.pm looks then like that:

  use uHTML ;

  sub Include($) {
  my $Node = shift;
    if $Node->Param('file') and
       open FH,$ENV{'DOCUMENT_ROOT'}.$Node->Param('file');


To link this small library into a website a cgi hook is needed. We place the necessary code in a file called hook.pl in the script directory:


  use uHTML ;

    or die "File: $ENV{'PATH_INFO'} not found";
  print "Content-type: text/html\n\n";
  print uHTML->recode(<FILE>);

To get the functionality “magically” into all *.uhtml files, we add some lines into the .htaccess file:

  RewriteEngine on
  RewriteRule ^(/?)(.*\.uhtml) $1cgi-bin/hook.pl/$2 [L,QSA]

This full working example shows just the basic integration of UHTML into a website. It do not show the use of variable parameters or request initialisation, but including any of this two is trivial.


Valid HTML 4.01 Transitional CSS is valide!

2008 All Rights Reserved Jorga Interactive | valid html 4.01 | valid css