[wp-hackers] Separation of Application Logic from

Ryan Boren ryan at boren.nu
Mon Sep 5 17:05:27 GMT 2005


On Sun, 2005-09-04 at 13:40 -0400, Nathan Lamont wrote:
> in the template. This is not about syntax, this is about abstraction.
> This is  so the template doesn't need to know how a decision is made.
> (Ideally it wouldn't be using string constants, e.g., `approved`,
> `none`, to check the comment's status.)

In 1.6, this is done as current_user_can('approve_comments'), a definite
improvement over the user level checks.

Your point about abstraction is well taken.  That's why hundreds of
lines of code have been moved out of the templates in 1.6.  More things
are abstracted with objects and template functions.  This effort to
encapsulate and abstract will continue and could use any help people
want to provide.

> No, Smarty isn't the only way to do this. But just as I wouldn't try
> to write a WordPress from scratch when such a beautiful job has been
> done with it already, so I wouldn't try to write a templating library
> when Smarty let me hit the ground running.
> Smarty would add 500K or so to WordPress's size,
> but it would be 500K of well written, well maintained, and field
> tested code.

I'd rather not redo all of WP's field tested code in Smarty.  Instead,
let's stick with PHP and just make the code better.  Bad code can be
written in both PHP and Smarty.  Let's write good PHP code.  Plus,
abstracting the existing application code would benefit any future move
to a template engine, should such a thing happen.

So, let's continue to clean up the admin templates by moving the heavy
lifting into functions.  I'd like to eliminate direct DB calls from the
templates as much as possible and improve code reuse.

Ryan



More information about the wp-hackers mailing list