The problem with referencing Smarty in the PHP class???
Problem Overview:
To call the Smarty method in a class, the following error occurs:
PHP Fatal error:using $this When not in object context in G:\SVN\YCMS\localhost\core\smarty\sysplugins\smarty_internal_d ata.php on line 38
Below the code, I hope you can help me under [app/model/home.php has introduced the _model class through other pages]:
app/model/home.php
PHP Code
core/model/index.php
PHP Code
Core/config/smarty
PHP Code
Template_dir = Y_app. DS. ' View ';//Set template directory $smarty->compile_dir = Y_cache. DS. " View_c ";//Set compile directory $smarty->config_dir = Y_app. DS. ' Config '. DS. ' Smarty ';//config directory variable//$smarty->php_handling = Smarty_php_allow; Deprecated set to Smarty_php_allow$smarty->left_delimiter = "{"; $smarty->right_delimiter = "}";//compile# $smarty Compile_check = false;//Compile check variable//cache$smarty->caching = true; The output of the cache template $smarty->cache_dir = Y_cache; Directory name where the template cache is stored # $smarty->cache_lifetime = 1; Cache life Cycle?>
There are no problems with file associations, some of which are not shown here.
The error is pointing to the Smarty source code, which is also posted here:
PHP Code
Public Function assign ($tpl _var, $value = null, $nocache = False) { if (Is_array ($tpl _var)) { foreach ($tpl _v Ar as $_key = $_val) { if ($_key! = ") { $this->tpl_vars[$_key] = new Smarty_variable ($_val, $nocache);
}}} else { if ($tpl _var! = ') { $this->tpl_vars[$tpl _var] = new Smarty_variable ($value, $ NoCache);}}}
Hope you feel free!
------Solution--------------------
Assign needs to be instantiated before it can be referenced, there is a sentence in your class home, Parent::assign () The parent class is not instantiated at all