[geeklog-devel] caching template library

Joe Mucchiello joe at ThrowingDice.com
Thu Nov 29 23:04:10 EST 2007

At 09:00 PM 11/29/2007, Mark R. Evans wrote:
>I have just implemented the {!if} processing into the latest 
>development version of Media Gallery.  I've decided that since this 
>caching library works so well, it is going to be a requirement to 
>run the next release of Media Gallery.

Conveniently, the template library is 1.4.1 compatible so you are not 
restricted by when you make that release. Heck, it's probably 
compatible with anything using this version of phplib.

You should probably talk about doing this on your website soon. Also, 
consider going to version 2.0 as you next release version rather than 
1.5.1 since this is a radical departure from 1.5.

>I still have a bit more work to do, but I must tell you it has 
>really streamlined my PHP code.  If I need something, I set it in 
>the code and no longer need to initialize the variable to ''.  It 
>has also made it a bit easier to control some of the design 
>items.  For example, on the main index page if there were 
>sub-albums, then I needed a column to display the subalbum info, for 
>those albums that had none, it just had a blank column.  Now I can 
>check if lang_subalbum is set, if not, dynamically call a td 
>colspan=2 and use the whole page width for that album display.

Is it in CVS yet? I'd love to see it. Are you using the {$LANG stuff? 
I'm curious how much that streamlines the PHP. I just don't have any 
complex enough pages where it would make a noticeable difference.

>Very cool stuff and I'm sure I'm only scratching the surface of its 
>Too bad the core team doesn't want to use it, but I can assure you 
>that many folks will if they want to take advantage of all the new, 
>neat features in Media Gallery :)

The only issue you might face is having to help folks install the 
caching library. Make sure you have extra time to field support 
requests after releasing. Hacking the library into Geeklog is not 
very straightforward for the uninitiated. I suppose I should start 
versioning my changes. Especially since...

I've been inspired again. The following template is valid in the 
latest version of the template library. Given the template and code 
that follow, you get the listed output. {!dec total} also works:

{!loop count}{count__loopvar} of {count}: {!inc total}<br>{!endloop}

$T->set_var('count', 3);
$T->parse('output', 'looptest');
$T->parse('output', 'looptest', true);
$T->set_var('count', 'oops, it\'s text');
$T->parse('output', 'looptest', true);
$T->set_var('count', -2);
$T->parse('output', 'looptest', true);

1 of 3: 1
2 of 3: 2
3 of 3: 3
1 of 3: 4
2 of 3: 5
3 of 3: 6
-1 of -2: 7
-2 of -2: 8

Joe Mucchiello
Throwing Dice Games

More information about the geeklog-devel mailing list