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 (35)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

July 3, 2009
Why Freelancing is Awesome
About
 
July 3, 2009
Twitter spurs Bing and Facebook real-time initiatives
WebDevTips UK
 
July 3, 2009
Maybe ?Paid? Is the Future of Online Business
WebDevTips UK
 
July 3, 2009
Will Microsoft, Google and Amazon talk you out of your datacentre?
WebDevTips UK
 
July 3, 2009
US Couple Gets Prison Time For Internet Obscenity
WebDevTips UK
 
July 3, 2009
Indenting Lists Consistently Across Different Browsers
About
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /PHP /Templating

PHP / Apache Templating 

  Views:    10233
  Votes:    0
by Ran Aroussi 5/15/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_prepend_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