Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarty 4 Error - unknown tag 'counter' #947

Closed
CodeEaseWithAnu opened this issue Mar 7, 2024 · 6 comments
Closed

Smarty 4 Error - unknown tag 'counter' #947

CodeEaseWithAnu opened this issue Mar 7, 2024 · 6 comments

Comments

@CodeEaseWithAnu
Copy link

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 :

_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() {} } ?>
@wisskid
Copy link
Contributor

wisskid commented Mar 7, 2024

What is the error you are getting?

@CodeEaseWithAnu
Copy link
Author

CodeEaseWithAnu commented Mar 7, 2024

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

{counter}
" unknown tag 'counter'

@wisskid
Copy link
Contributor

wisskid commented Mar 7, 2024

And can you show us the code of the template that causes the error?

@CodeEaseWithAnu
Copy link
Author

CodeEaseWithAnu commented Mar 7, 2024

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 ?

@wisskid
Copy link
Contributor

wisskid commented Mar 7, 2024

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.

@CodeEaseWithAnu
Copy link
Author

Thank you worked

@wisskid wisskid closed this as completed Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants