Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Common header and footer using HTML::Template

Status
Not open for further replies.

rakeshou

Programmer
Aug 15, 2006
17
US
Hello all,

I am using HTML::Template to separate the design from logic. As of now I am using html header and footer in all template pages as under:

Code:

<div id="header"> <h1><a id="bigtext" title="Go to home page" href="home.pl">TITLE</a></h1> <div id="links"> <text2 id="text2">Logged in as <TMPL_VAR NAME=USERNAME></text2> <a href="get_email.pl">Invite</a> | <a href="help.pl">Help</a> | <a href="logout.pl">Logout</a> </div> </div



but I want to have this code in one file and want to include that file in all the pages.

Any suggestions will be appreciated.

Rakish
 
have you tried server side includes (SSI)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Create a html template file then insert something like +++ where you want to have the logic displayed. Then just have your script split the template file at the plusses.
 
The HTML::Template module also has functionality for including a template into a template.
TMPL_INCLUDE
<TMPL_INCLUDE NAME="filename.tmpl">
This tag includes a template directly into the current template at the point where the tag is found. The included template contents are used exactly as if its contents were physically included in the master template.

The file specified can be an absolute path (beginning with a '/' under Unix, for example). If it isn't absolute, the path to the enclosing file is tried first. After that the path in the environment variable HTML_TEMPLATE_ROOT is tried, if it exists. Next, the "path" option is consulted, first as-is and then with HTML_TEMPLATE_ROOT prepended if available. As a final attempt, the filename is passed to open() directly. See below for more information on HTML_TEMPLATE_ROOT and the "path" option to new().

As a protection against infinitly recursive includes, an arbitary limit of 10 levels deep is imposed. You can alter this limit with the "max_includes" option. See the entry for the "max_includes" option below for more details.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Thanks for the help,
I will try to include another template in a template and see how it goes..

Regards,

Rock
 
Dear 1DMF and others,

<TMPL_INCLUDE NAME="filename.tmpl">

worked like a charm

Thank you..

Really appreciate it.

Rakesh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top