|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
zWaR Smarty n00b
Joined: 26 May 2006 Posts: 2
|
Posted: Fri May 26, 2006 7:21 pm Post subject: Smarty does not recognize my modifier |
|
|
Hello. I've writen a modifier, which replaced some strings with phps str_replace function and everything worked well. Now i deleted the modifier and created another one, which doesn't work. Smarty always says there is no such modifier. If i use the old one insted it works!!! (althought i deleted it and unregistered it, i tried to delete smarty, its folders, nothing works, it's stil the same - the old modifier works, the new one doesn't)
Here's the code (modifier.styles.php):
Code: |
<?php
function smarty_modifier_getClass($subject) {
$pom=explode("<",$subject);
$returnVal=rtrim($pom[1],">");
return($returnVal);
}
?>
|
Template (New.tpl)
Code: |
{!# $class|getClass:$column.$second #!}
|
php code from where i call smarty:
Code: |
$smarty=new Smarty();
$smarty->left_delimiter = '{!#';
$smarty->right_delimiter = '#!}';
$smarty->template_dir="templates";
$smarty->compile_dir="templates_c";
$smarty->config_dir="config";
$smarty->cache_dir="cache";
$smarty->plugins_dir="plugins";
$smarty->assign('toExcel',$toExcel);
$smarty->register_modifier('styles','getClass');
$smarty->display('New.tpl');
|
Please help me, i'm totaly stuck! |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri May 26, 2006 9:56 pm Post subject: |
|
|
You registered your modifier using:
$smarty->register_modifier('styles','getClass');
but you are referencing the modifier as "getClass" in the template (not "styles") and are using 'getClass' as the callback when the function is really named 'smarty_modifier_getClass'. Chances are you don't want to manually register but would rather use the autoloading mechanism by simply putting the plugin into its own file within the plugins directory named 'modifier.getClass.php' with a function name 'smarty_modifier_getClass'. The manual has more details |
|
Back to top |
|
zWaR Smarty n00b
Joined: 26 May 2006 Posts: 2
|
Posted: Sat May 27, 2006 6:52 am Post subject: |
|
|
boots, thank you!!! You just gave me a kick into the right direction it works now!! |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|