(Yaf >=1.0.0)
The assignRef purpose
public bool Yaf_View_Simple::assignRef ( string $name, mixed &$value )
unlike Yaf_View_Simple::assign(), this method assign a ref value to engine.
Parameters:
name
A string name which will be used to access the value in the tempalte.
value
mixed value
Returns:
Examples:
Yaf_View_Simple::assignRef() example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <?php class IndexController extends Yaf_Controller_Abstract { public function indexAction() { $value = "bar" ; $this ->getView()->assign( "foo" , $value ); /* plz note that there was a bug before Yaf 2.1.4, * which make following output "bar"; */ $dummy = $this ->getView()->render( "index/index.phtml" ); echo $value ; //prevent the auto-render Yaf_Dispatcher::getInstance()->autoRender(FALSE); } ?> |
template() example
1 2 3 4 5 6 7 | <html> <head> <title><?php echo $foo ; $foo = "changed" ; ?></title> </head> <body> </body> </html> |
The above example will output something similar to:
/* access the index controller will result: */ changed
See also:
Please login to continue.