iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (34)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

May 13, 2008
Rainbow Links
EarthWeb.com
 
May 13, 2008
MySpace Profile Page Resources
HTML Goodies
 
May 13, 2008
How to Upload Your Photos onto the Web
HTML Goodies
 
May 13, 2008
Email Marketing for MySpace Artists
HTML Goodies
 
May 13, 2008
Top Online Marketing Techniques
HTML Goodies
 
May 13, 2008
I want to create a site just like ____, is that a violation of...
About
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /PHP /Templating

PHP / Apache Templating 

  Views:    8638
  Votes:    0
by Ran Aroussi 6/04/05 Rating: 

Synopsis:

Here's a quick tip to have a simple template-based website. I use this method on my Textpattern-powered site and it works great! This method does not requires any installation of PHP template engines such as Smarty, XTemplate, etc. All it takes is 2 lines in your .htaccess file. So, how am I doing it? Sort answer: using Apache directives.
Pages: 
The Article

Here's a quick tip to have a simple template-based website. I use this method on my Textpattern-powered site and it works great!

This method does not requires any installation of PHP template engines such as Smarty, XTemplate, etc. All it takes is 2 lines in your .htaccess file.

Well, how am I doing it?

Sort answer: using Apache directives.

Longer answer: using Apache directives to auto-append and auto-prepend header and footer files.

To achieve this, do the following:

  1. Create an HTML/PHP file with your design layout.
  2. Break this file into 3 portions, before dynamic content, content, and after dynamic content.
  3. Save the before portion as header.php and the after portion as footer.php in your server’s root directory.
  4. In your .htaccess, add the following lines:
    php_value  auto_prepend_file  /header.php
    php_value  auto_append_file  /footer.php
  5. That’s it.

Now, create your website as you normally would. Every time your pages will load, Apache will automatically “wrap” them with your header and footer files, producing your desired end result.

I recommend using the .html file extension for the header and footer files to save server load if your pages are not dynamic pages.

PLEASE NOTE: Your webhost may not allow you to use these Apache directives, so be sure to check that out before hand.

Pages: 

Similar/related articles:


 
  Sponsors