class.rFastTemplate.php
Long ago, in a galaxy far, far, away….
Seriously, I encountered class.FastTemplate.php while doing a consulting job in in the last millenium. It had a lot of nifty features I liked, but there were some rough edges with some incomplete features, the biggest of which was it’s recursive template feature. Since LISP was the first programming language I learned, I’m kind of fond of recursion, so I started writing my own replacement with class.FastTemplate.php compatibility as a major goal. In the process, I also took advantage of some things which may not have existed when class.FastTemplate.php was written, namely the ability to return and pass around variable by reference. That trick made class.rFastTemplate.php really fast compared to the original. Okay, at least for my cases and I’ve had others tell me the same thing. I don’t have any benchmarks—you’ll have to do your own.
One of the things I like about the template approach in general is the ability to separate code from content. And, in fact, I like to separate things into code, layout, and content. That’s sort of the point of the template, it provides the layout, the content lives elsewhere, and there is some code that puts its all together. My original website quickly morphed into something that used my new class.rFastTemplate.php exclusively to maintain consistency throughout. Eventually, the world passed me by and I found I really wanted a content management system to make my life easier. Ah, but using a CMS comes with a price: I get what the authors think are cool features which for me meant reduced flexibility in a number of areas. Oh well, life is about trade-offs.
Even then, I decide that I liked my own templating system enough that I wrote a new theme for Drupal called (tada!) astrofoto. The obvious things it includes are all the CSS changes to get the lovely color scheme you are currently viewing. But I didn’t like the mixture of code and format information in the default Drupal themes, so I split them apart using (you’re way ahead of me, I see) class.rFastTemplate.php.
My use of class.rFastTemplate.php is not really a new theme engine in Drupal, it works in conjunction with the default theme engine in a sort of hybrid mode. XTemplate loads my PHP fragments which use class.rFastTemplate. But for me, the big win is that my layout is easy to read and I don’t have to touch the code to change it. And much of it can be modified via CSS (like the default Drupal theme on which is was based).
Your old templates should work just fine. If they don’t, please let me know. Comptability was one of the goals; to have a real drop-in replacement for class.FastTemplate. I like the nested template structure, but I didn’t want to have to go back and change all my templates. Grab a copy and try it out. Let me know what you think. I called it “rFastTemplate” for “recursive” but it’s not really any different in functionality than the original. It’s hard to come of with a name as catchy as FastTemplate and stealing the original name didn’t seem quite right (not to mention the potential for confusion.
Oh, there is one thing you will have to change in your PHP code that uses the new class: the name. You will need to change
require "class.FastTemplate.php3"; ... $t = new FastTemplate ($template_directory);
to
require "class.rFastTemplate.php"; ... $t = new rFastTemplate ($template_directory);
Around June 1, 2001, I modified the code to no longer emit the
<!-- BEGIN DYNAMIC BLOCK: foo --> <!-- END DYNAMIC BLOCK: foo -->
HTML comments when it spits out the parsed template. This makes it easier to hide the fact that you are using a template and also reduces the amount of text flowing over the net (in some cases by a lot).
Search
.Archives
- August 2025 (1)
- July 2025 (1)
- May 2025 (3)
- October 2024 (1)
- May 2024 (2)
- April 2024 (3)
- September 2022 (5)
- April 2022 (1)
- January 2022 (3)
- December 2021 (4)
- September 2021 (3)
- July 2021 (1)
- January 2021 (1)
- November 2020 (2)
- October 2020 (2)
- September 2020 (2)
- August 2020 (5)
- July 2020 (1)
- November 2019 (2)
- September 2019 (1)
- August 2019 (2)
- September 2017 (1)
- August 2017 (1)
- September 2015 (3)
- August 2015 (2)
- June 2015 (5)
- May 2015 (3)
- May 2013 (2)
- January 2013 (1)
- December 2012 (2)
- September 2012 (1)
- June 2012 (1)
- May 2012 (1)
- October 2011 (2)
- September 2011 (2)
- April 2011 (2)
- March 2011 (10)
- January 2011 (8)
- November 2010 (2)
- October 2010 (1)
- September 2010 (3)
- August 2010 (2)
- July 2010 (1)
- June 2010 (1)
- April 2010 (3)
- February 2010 (3)
- January 2010 (3)
- December 2009 (6)
- November 2009 (3)
- October 2009 (7)
- September 2009 (8)
- August 2009 (4)
- July 2009 (1)
- June 2009 (2)
- May 2009 (2)
- April 2009 (7)
- March 2009 (1)
- February 2009 (6)
- January 2009 (4)
- December 2008 (4)
- November 2008 (3)
- October 2008 (11)
- September 2008 (4)
- August 2008 (5)
- July 2008 (5)
- June 2008 (2)
- April 2008 (4)
- March 2008 (18)
- February 2008 (9)
- November 2007 (1)
- October 2007 (3)
- July 2007 (3)
- April 2007 (1)
- March 2007 (6)
- February 2007 (3)
- December 2006 (3)
- October 2006 (4)
- September 2006 (1)
- July 2006 (5)
- May 2006 (10)
- April 2006 (9)
