Symfony Template系统内建的一些常用变量
在Symfony Template的系统中有一些经常使用的内建对象,这项可以减轻Model的处理程序中的一些负担,而不需把任何简单的变量都必须先赋值给View,而View中再次使用赋值变量来显示.而让Template可以直接把一些简单变量显示在页面中.
1. $sf_context: The whole context object (instance of sfContext)
2. $sf_request: The request object (instance of sfRequest)
3. $sf_params: Parameters of the request
4. $sf_user: The current user session object (instance of sfUser)
简单的代码:
// Long version
<?php echo $sf_request->getParameter(‘total’); ?>// Shorter version
<?php echo $sf_params->get(‘total’); ?>// Equivalent to the following action code
echo $this->getRequestParameter(‘total’);
尚无评论