Closed MildaGeorge closed 5 months ago
What is the error you are getting?
After upgrading to Smarty 4, I'm encountering an unknown tag 'counter' error. The {counter} custom function is not working as expected. The code was previously running on an older version of Smarty without any issues. Error : Syntax error in template costcenterlist.tpl - > on line 39
And can you show us the code of the template that causes the error?
sure{counter} its a tpl file and {counter} is custom function of smarty right? i cant post complete code and $this->_engine->setPluginsDir(array( $config->paths->base . '/library/Templater/plugins' )); This is my templater.php code need to add plugin folder here ?
No, I meant the source code of costcenterlist.tpl
Also, try to use addPluginDir instead of setPluginDir and/or make sure your plugin dir contains the counter plugin file.
Thank you worked
I am stuck with smarty 4 issue unknown tag 'counter' with custom function {counter} while upgrading to smarty 4. How can i fix it. I am using php 8.2 and framework Zend.I ma new to smarty. here i provide my templater.php details : <?php class Templater extends Zend_View_Abstract { protected $_path; protected $_engine;
public function construct() { parent::construct();
$config = Zend_Registry::get('config');
// Include the Smarty class require_once 'Smarty/libs/Smarty.class.php'; require_once 'Templater/plugins/smarty-gettext.php';
// Create an instance of Smarty $this->_engine = new Smarty();
// Set Smarty configurations $this->_engine->setTemplateDir($config->paths->templates); $this->_engine->setCompileDir(sprintf('%s/tmp/templates_c', $config->paths->data)); $this->_engine->setPluginsDir(array( $config->paths->base . '/library/Templater/plugins', 'libs/plugins' ));
//$this->_engine->registerBlock('t', 'smarty_translate'); $this->_engine->registerPlugin('block', 't', 'smarty_translate');
$this->_engine->debugging = true; $this->_engine->error_reporting = E_ALL & ~E_NOTICE;
}
public function getEngine() { return $this->_engine; }
public function __set($key, $val) { $this->_engine->assign($key, $val); }
public function __get($key) { return $this->_engine->getTemplateVars($key); }
public function __isset($key) { return $this->_engine->getTemplateVars($key) !== null; }
public function __unset($key) { $this->_engine->clearAssign($key); }
public function assign($spec, $value = null) { if (is_array($spec)) { $this->_engine->assign($spec); return; } $this->_engine->assign($spec, $value); }
public function clearVars() { $this->_engine->clearAllAssign(); }
public function render($name) { return $this->_engine->fetch(strtolower($name)); } public function _run() {} } ?>