Online advertising

Hebrew Site

 

Affiliate Marketing (R)Evolution

Job Offers

I Love to Rant!

Backpack: Get Organized and Collaborate

14 May 2005, 14:14 Apache Templating

I recently got an email from Scot Jandly who asked me weather the different sections on my TXP-powered site are hard-coded into the HTML, or am I somehow hiding the article name in the URL.

While different sections on this site really just have a TXP tag to load a certain article, the URLs for different sections include just the section name, but not the article name.

So, how am I doing this?

Sort answer: using Apache directives.

I am basically using 5 templates to show different content. I have setup 5 different sections on my site, each section is using a different template. The section ‘colophon’ uses the template ‘colophon’, ‘elsewhere’ uses ‘elsewhere’ and so on…

The templates are each comprised of a single TXP tag. For example, the template ‘archive’ only writes: <txp:rss_suparchive showsubdate="1" section="article" dateformat="F Y" />

and the section ‘elsewhere’ only writes:
<txp:linklist form="Links" sort="linksort" />

Now, the trick to get all the sections look & feel the same, is to use Apache directives to auto-append and auto-prepend the 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 every time your sections will load, Apache will automatically “wrap” them with your header and footer files, producing your end result.

I recommend using the .html file extension 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.

{ tags:  apache, code, tricks }

 

 

Comments

Post your comments:

Basic Textile Help is enabled:
*bold* · _italic_ · "Link Text":http://foo.com

Name:

Email:

HTTP://:


me

 

Tip! Get a GRAVATAR and have a personalized avatar displayed next to your comment(s).

 

 

Entries by Tag:

advertising, apache, apple, apps, bidmini, blog, blogish, browsers, bsd, business, code, copywriting, danielle, del.icio.us, ebay, elsewhere, emma, family, firefox, funny, gmail, google, gravatars, greetings, hlola, ipod, israel, opera, osx, personal, photoshop, php, politics, projects, rants, safari, textpattern, todo, tools, trackback, tricks, unix, video, web2.0, widgets, windows