October 16, 2006

AJAX with Smarty? It can be done!

Under normal circumstances, once you’ve passed your footer template to Smarty->display(), you’re done. There’s no going back without a refresh. Well, that was before Dmytro Shteflyuk wrote a sexy PHP library, aptly named smarty_ajax.

It does have some limitations, however; one of which is a complete lack of support for object-oriented PHP. I modified smarty_ajax’s ajax_update and ajax_call tools and (among other things) added an optional parameter, object=”". Now you can call class methods from the client with just one line of code, and display their output, all without giving up Smarty as your templating engine!

Since I haven’t yet had a chance to contact Mr. Shteflyuk about committing my patch, you can stare at, download, play with and mangle my version from here for the mean time. But if you break something, don’t expect him to know anything about it! Comment here or email me for help instead, until it is released.

peace

Leave a reply

Inspiration

6pli Tumblr Aptana IDE Markus Homm Mint Humanized Rawkus Records // All Things Hip Hop // www.rawkus.com The New York Times WeShouldDoItAll Justinsomnia Deluxe Digital Media Democracy Internet Tv Take More Photos fluxiom - capture, manage, access and deliver content across your enterprise Olivier Danchin Jason Santa Maria Tubetorial Ajaxian Raincity Studios 88 Miles - Simple time tracking Welcome to Zopa (UK) - The first lending and borrowing exchange Inspirational design for a web2.0 homepage