Smarty validation class

Smarty validation class

This is a class used to validate a Smarty template. It basically just runs the normal Smarty parser, trapping all the errors then returning them in array.

Very useful for a web-based template editor.

This class requires Smarty to be installed.

validateTemplate(’mytemplate.tpl’);

var_dump($errors);

if (count($errors) == 0)

; // no errors

else

; // 1 or more errors occurred

?>

Also, you can optionally validate resources to see if they exist. For example, if you have something like:

{include file=’another.tpl’}

Then if you pass the validateResources option as true to the validateTemplate() method, it will make sure that another.tpl exists.

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.