Re: [fw-general] Smarty integration
Forgot the attachment. On 2/21/07, highland <[EMAIL PROTECTED]> wrote: Hello I does not work for me, i've made my view class from the code you provided (edit only smarty paths), when i try to: $view->assign('Title','test page'); $view->assign('main_data','main_site_data.tpl'); $this->_response->setBody($view->render('main_site_template.tpl')); i receive my main_site_template.tpl template code: (instead of data): {include file="header.tpl"} {include file="$main_data"} {include file="menu_top.tpl"} {include file="menu_left.tpl"} #top Top of page {include file="logo.tpl"} {include file="footer.tpl"} Why ? > Hi, > > I'd like to recommend you implement Zend_View interface instead of > extend the abstract class and the render method can be simply like this > without any problem: > > public function render($name) > { > return $this->_smarty->fetch($name); > } > > if you look into Smarty's source code, you will find the display() method > calls fetch() > and prints the output. > > Just my two cents. > > Jason. I agree. It's much easier to implement the interface for a non-php based My take: http://akrabat.com/2006/12/23/extending-zend_view_interface-for-use-with-smarty/ Regards, Rob... -- View this message in context: http://www.nabble.com/Smarty-integration-tf3260325s16154.html#a9078402 Sent from the Zend Framework mailing list archive at Nabble.com. -- Craig Slusher [EMAIL PROTECTED] Smarty.php Description: Binary data
Re: [fw-general] Smarty integration
I have attached a copy of my Sleek_View_Smarty class I wrote. Feel free to rename it and use it for yourself. It works great for me. I can render smarty templates no problem. On 2/21/07, highland <[EMAIL PROTECTED]> wrote: Hello I does not work for me, i've made my view class from the code you provided (edit only smarty paths), when i try to: $view->assign('Title','test page'); $view->assign('main_data','main_site_data.tpl'); $this->_response->setBody($view->render('main_site_template.tpl')); i receive my main_site_template.tpl template code: (instead of data): {include file="header.tpl"} {include file="$main_data"} {include file="menu_top.tpl"} {include file="menu_left.tpl"} #top Top of page {include file="logo.tpl"} {include file="footer.tpl"} Why ? > Hi, > > I'd like to recommend you implement Zend_View interface instead of > extend the abstract class and the render method can be simply like this > without any problem: > > public function render($name) > { > return $this->_smarty->fetch($name); > } > > if you look into Smarty's source code, you will find the display() method > calls fetch() > and prints the output. > > Just my two cents. > > Jason. I agree. It's much easier to implement the interface for a non-php based My take: http://akrabat.com/2006/12/23/extending-zend_view_interface-for-use-with-smarty/ Regards, Rob... -- View this message in context: http://www.nabble.com/Smarty-integration-tf3260325s16154.html#a9078402 Sent from the Zend Framework mailing list archive at Nabble.com. -- Craig Slusher [EMAIL PROTECTED]
Re: [fw-general] Smarty integration
Hello I does not work for me, i've made my view class from the code you provided (edit only smarty paths), when i try to: $view->assign('Title','test page'); $view->assign('main_data','main_site_data.tpl'); $this->_response->setBody($view->render('main_site_template.tpl')); i receive my main_site_template.tpl template code: (instead of data): {include file="header.tpl"} {include file="$main_data"} {include file="menu_top.tpl"} {include file="menu_left.tpl"} #top Top of page {include file="logo.tpl"} {include file="footer.tpl"} Why ? > Hi, > > I'd like to recommend you implement Zend_View interface instead of > extend the abstract class and the render method can be simply like this > without any problem: > > public function render($name) > { > return $this->_smarty->fetch($name); > } > > if you look into Smarty's source code, you will find the display() method > calls fetch() > and prints the output. > > Just my two cents. > > Jason. I agree. It's much easier to implement the interface for a non-php based My take: http://akrabat.com/2006/12/23/extending-zend_view_interface-for-use-with-smarty/ Regards, Rob... -- View this message in context: http://www.nabble.com/Smarty-integration-tf3260325s16154.html#a9078402 Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Smarty integration
Jason Qi wrote: > Hi, > > I'd like to recommend you implement Zend_View interface instead of > extend the abstract class and the render method can be simply like this > without any problem: > > public function render($name) > { > return $this->_smarty->fetch($name); > } > > if you look into Smarty's source code, you will find the display() method > calls fetch() > and prints the output. > > Just my two cents. > > Jason. I agree. It's much easier to implement the interface for a non-php based My take: http://akrabat.com/2006/12/23/extending-zend_view_interface-for-use-with-smarty/ Regards, Rob...
Re: [fw-general] Smarty integration
Hi, I'd like to recommend you implement Zend_View interface instead of extend the abstract class and the render method can be simply like this without any problem: public function render($name) { return $this->_smarty->fetch($name); } if you look into Smarty's source code, you will find the display() method calls fetch() and prints the output. Just my two cents. Jason. highland <[EMAIL PROTECTED]> wrote: Hello I created my own class extending Zend_View_Abstract and including smarty. I wanted to be able to use smarty templates and zend render on the same object. Here is my code: class MyView extends Zend_View_Abstract { private $_smarty = false; public function __construct($data = array()) { parent::__construct($data); $config = Zend::registry('config'); $this->_smarty = new Smarty(); $main_path = $config->path->server.$config->path->homepage; $this->_smarty->template_dir = $main_path.$config->smarty->template_dir; $this->_smarty->compile_dir = $main_path.$config->smarty->compile_dir; $this->_smarty->config_dir = $main_path.$config->smarty->config_dir; $this->_smarty->cache_dir = $main_path.$config->smarty->cache_dir; } protected function _run($template=null) { print parent::render($template); } public function display($template) { $this->_smarty->display($template); } public function assign($var, $value=null) { if (is_string($var)) { $value = @func_get_arg(1); $this->_smarty->assign($var, $value); } elseif (is_array($var)) { foreach ($var as $key => $value) { $this->_smarty->assign($key, $value); } } else { throw new Zend_View_Exception('assign() expects a string or array, got '.gettype($var)); } } public function escape($var) { if (is_string($var)) { return parent::escape($var); } elseif (is_array($var)) { foreach ($var as $key => $val) { $var[$key] = $this->escape($val); } return $var; } else { return $var; } } public function output($name) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); header("Cache-Control: post-check=0, pre-check=0", FALSE); print parent::render($name); } public function render($name) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); header("Cache-Control: post-check=0, pre-check=0", FALSE); print parent::render($name); } public function isCached($template) { if ($this->_smarty->is_cached($template)) { return true; } return false; } public function setCaching($caching) { $this->_smarty->caching = $caching; } } ?> in Controller for drawing using smarty i use: $view->display('smarty_template.tpl') and it works fine. But i want also to be able to use on the same $view object Zend render (so i could process php code), so i tried: $view->render('zend_template.tpl.php') But Zend returned: Zend_View_Exception: script './application/views/zend_template.tpl.php' not found in path in /usr/share/php/Zend/View/Abstract.php on line 571 Why ? How can i correct it ? Thanx -- View this message in context: http://www.nabble.com/Smarty-integration-tf3260325s16154.html#a9061125 Sent from the Zend Framework mailing list archive at Nabble.com. - We won't tell. Get more on shows you hate to love (and love to hate): Yahoo! TV's Guilty Pleasures list.
[fw-general] Smarty integration
Hello I created my own class extending Zend_View_Abstract and including smarty. I wanted to be able to use smarty templates and zend render on the same object. Here is my code: _smarty = new Smarty(); $main_path = $config->path->server.$config->path->homepage; $this->_smarty->template_dir = $main_path.$config->smarty->template_dir; $this->_smarty->compile_dir = $main_path.$config->smarty->compile_dir; $this->_smarty->config_dir = $main_path.$config->smarty->config_dir; $this->_smarty->cache_dir = $main_path.$config->smarty->cache_dir; } protected function _run($template=null) { print parent::render($template); } public function display($template) { $this->_smarty->display($template); } public function assign($var, $value=null) { if (is_string($var)) { $value = @func_get_arg(1); $this->_smarty->assign($var, $value); } elseif (is_array($var)) { foreach ($var as $key => $value) { $this->_smarty->assign($key, $value); } } else { throw new Zend_View_Exception('assign() expects a string or array, got '.gettype($var)); } } public function escape($var) { if (is_string($var)) { return parent::escape($var); } elseif (is_array($var)) { foreach ($var as $key => $val) { $var[$key] = $this->escape($val); } return $var; } else { return $var; } } public function output($name) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); header("Cache-Control: post-check=0, pre-check=0", FALSE); print parent::render($name); } public function render($name) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); header("Cache-Control: post-check=0, pre-check=0", FALSE); print parent::render($name); } public function isCached($template) { if ($this->_smarty->is_cached($template)) { return true; } return false; } public function setCaching($caching) { $this->_smarty->caching = $caching; } } ?> in Controller for drawing using smarty i use: $view->display('smarty_template.tpl') and it works fine. But i want also to be able to use on the same $view object Zend render (so i could process php code), so i tried: $view->render('zend_template.tpl.php') But Zend returned: Zend_View_Exception: script './application/views/zend_template.tpl.php' not found in path in /usr/share/php/Zend/View/Abstract.php on line 571 Why ? How can i correct it ? Thanx -- View this message in context: http://www.nabble.com/Smarty-integration-tf3260325s16154.html#a9061125 Sent from the Zend Framework mailing list archive at Nabble.com.