From: Jason S. <jsw...@ya...> - 2003-01-07 22:59:57
|
This message is in reply to Ross Keatinge's message (from 1969 according to sf.net!) I reworked the hello demo to use Smarty instead of xls (the production server here at work is not compiled with xls support). This is what I changed: Altered the mappings.php file to specify templates instead of xls: <?php //build mapping information to pass into controller $mappings = array( _ACTION_FORMS => array( 'form' => array( _TYPE => 'HelloForm' ) ), _ACTION_MAPPINGS => array( 'sayHello' => array( _TYPE => 'HelloAction', _NAME => 'form', _INPUT => 'index.php?view=index.tpl', _VALIDATE => 1, _ACTION_FORWARDS => array( 'hello' => array( _PATH => 'index.php?view=hello.tpl', _REDIRECT => 0 ), 'index' => array( _PATH => 'index.php?view=index.tpl', _REDIRECT => 0 ) ) ) ) ); ?> Created these templates under the view directory: index.tpl: <html> <head> <title>Phrame - Example Application</title> </head> <body> <form action="phrame.php" method="post"> {if $errors|@count gt 0} <ul> {section name=e loop=$errors} <li><b style="color: red">{$errors[e]}</b></li> {/section} </ul> {/if} <p>What is your name?<br/> <input type="text" name="name" value="{$name}"/> <input type="submit" value="OK"/></p> <input type="hidden" name="action" value="sayHello"/><br/> </form> </body> </html> hello.tpl: <html> <head> <title>Phrame - Example Application</title> </head> <body> <p>Hello {$name}</p> <a href="index.php">Back</a></body> </html> And made these changes to the index.php file: <?php include('include/include.php'); require_once('Smarty.class.php'); session_start(); $t = new Smarty; $t->template_dir = 'views'; if ($_SESSION[_ERRORS]) { $t->assign('errors', $_SESSION[_ERRORS]->toArray()); $_SESSION[_ERRORS] = false; } if ($_SESSION[_FORM]) { $t->assign('forms', $_SESSION[_FORM]); } if ($_SESSION['person']) { $t->assign('name', $_SESSION['person']->getName()); } $template = ($_GET[_VIEW]) ? $_GET[_VIEW] : 'index.tpl'; $t->display($template); ?> __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com |