News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matthew Weir O'Phinney's Blog:
Cgiapp2 Tutorial 2 - Pluggable Applications
June 07, 2006 @ 06:17:36

Matthew Weir O'Phinney has created yet another tutorial surrounding the Cgiapp2software and looks this time at something he calls "pluggable applications".

He gives the example of needing a method for creating a well-structured layout in his appication, but also needing a sitewide template to apply to it. Traditional methods don't quite lend themselves to that, so he introduces a new function, cgiapp_postrun, to apply the template after the logic is through.

He includes two examples, one demonstrating the above mentioned situation and the other showing how to make a flexible method for including authentication in only certain parts of the application and not others. Both define a postrun() function to handle the changes to be made after the rest of the logic has finished.

0 comments voice your opinion now!
cgiapp2 tutorial pluggable application sitewide template authentication cgiapp2 tutorial pluggable application sitewide template authentication


Matthew Weir O'Phinney's Blog:
Cgiapp2 Tutorial 1 - Switch Template Plugins at Will
June 06, 2006 @ 05:47:28

Right on the tails of a new release of the Cgiapp set of libraries, Matthew Weir O'Phinney has posted a first tutorial in a series covering its usage. In this tutorial, he looks at a creating a "template switcher" for Cgiapp2-based applications.

Cgiapp2 implements a new callback hook system, which is basically an Observer pattern. Cgiapp2 has a number of registered hooks to which observers can attach; when a hook is triggered, each observer attached to it is notified and executed.

Why all this talk about hooks? Because in Cgiapp2, the various template actions -- initialization, variable assignment, and rendering -- are relegated to hooks. For simplicity's sake, and for backward compatibility, you can use the functions tmpl_path(), tmpl_assign(), and load_tmpl() to invoke them; you could also use the generic call_hook() method to do so, passing the hook name as the first argument.

To make it simpler for developers to access this templating system, Matthew created the Cgiapp2_Plugin_Template_Interface, a standardized interface for the template plugins. It's this interface that he demonstrated an example of, giving only a few lines of code (all that's needed) to switch between Smarty and Savant templating systems.

0 comments voice your opinion now!
tutorial cgiapp2 template switch plugin interface tutorial cgiapp2 template switch plugin interface



Community Events





Don't see your event here?
Let us know!


symfony bugfix conference series interview introduction code deployment framework zendserver tips threedevsandamaybe voicesoftheelephpant laravel list api release community language podcast

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework