Open skjamil opened 7 years ago
I have found that the $_debug is defined at smarty_internal_debug.php file which is not included in smaty.class.php. By including that file the problem is still not solved.
$CI->smarty->_debug->display_debug($CI->smarty, TRUE); Commenting the above line in MY_Output.php file resolves the issue but I didn't get it really.
Hi,
No need to comment the line in question. To resolve this issue, check if the debug mode is turned ON or OFF.
if ($CI->smarty->debugging)
{
$CI->smarty->_debug->display_debug($CI->smarty, TRUE);
}
Hi,
I tried the solution of the friend moudarir, but I did not succeed, you managed to solve
Hi,
Code in "core/MY_Output.php" class
class MY_Output extends CI_Output {
public function _display($output = '')
{
parent::_display($output);
$CI =& get_instance();
if ($CI->smarty->debugging)
{
$CI->smarty->_debug->display_debug($CI->smarty, TRUE);
}
}
}
Code in "libraries/Smarty.php" Class
class CI_Smarty extends Smarty {
public $template_ext = '.php';
public function __construct() {
parent::__construct();
// Store the Codeigniter super global instance... whatever
$CI = get_instance();
// Load the Smarty config file
$CI->load->config('smarty');
// Turn on/off debug
$this->debugging = $CI->config->item('smarty.smarty_debug');
// Set some pretty standard Smarty directories
$this->setCompileDir($CI->config->item('smarty.compile_directory'));
$this->setCacheDir($CI->config->item('smarty.cache_directory'));
$this->setConfigDir($CI->config->item('smarty.config_directory'));
// Default template extension
$this->template_ext = $CI->config->item('smarty.template_ext');
// How long to cache templates for
$this->cache_lifetime = $CI->config->item('smarty.cache_lifetime');
// Disable Smarty security policy
$this->disableSecurity();
// If caching is enabled, then disable force compile and enable cache
if ( $CI->config->item('smarty.cache_status') === TRUE )
{
$this->enable_caching();
}
else
{
$this->disable_caching();
}
// Set the error reporting level
$this->error_reporting = $CI->config->item('smarty.template_error_reporting');
// This will fix various issues like filemtime errors that some people experience
// The cause of this is most likely setting the error_reporting value above
// This is a static function in the main Smarty class
Smarty::muteExpectedErrors();
// Should let us access Codeigniter stuff in views
// This means we can go for example {$this->session->userdata('item')}
// just like we normally would in standard CI views
$this->assign("this", $CI);
}
/**
* Enable Caching
*
* Allows you to enable caching on a page by page basis
* @example $this->smarty->enable_caching(); then do your parse call
*/
public function enable_caching()
{
$this->caching = 1;
}
/**
* Disable Caching
*
* Allows you to disable caching on a page by page basis
* @example $this->smarty->disable_caching(); then do your parse call
*/
public function disable_caching()
{
$this->caching = 0;
}
}
The config file "config/smarty.php"
// Smarty caching enabled by default unless explicitly set to FALSE
$config['smarty.cache_status'] = FALSE;
// The path to the themes
// Default is implied root directory/themes/
$config['smarty.theme_path'] = APPPATH.'views/templates/';
// The default name of the theme to use (this can be overridden)
$config['smarty.theme_name'] = "default";
// Cache lifetime. Default value is 3600 seconds (1 hour) Smarty's default value
$config['smarty.cache_lifetime'] = 3600;
// Where templates are compiled
$config['smarty.compile_directory'] = APPPATH."cache/smarty/compiled/";
// Where templates are cached
$config['smarty.cache_directory'] = APPPATH."cache/smarty/cached/";
// Where Smarty configs are located
$config['smarty.config_directory'] = APPPATH."third_party/Smarty/configs/";
// Default extension of templates if one isn't supplied
$config['smarty.template_ext'] = 'tpl';
// Error reporting level to use while processing templates
$config['smarty.template_error_reporting'] = E_ALL & ~E_NOTICE;
// Debug mode turned on or off (TRUE / FALSE)
$config['smarty.smarty_debug'] = FALSE;
// UPDATE - Allow php templates
$config['smarty.allow_php_templates'] = TRUE;
Hope that can help you.
Hi moudarir, very thanks you solution 100% resolved my question .
Hi,
Code in "core/MY_Output.php" class
class MY_Output extends CI_Output { public function _display($output = '') { parent::_display($output); $CI =& get_instance(); if ($CI->smarty->debugging) { $CI->smarty->_debug->display_debug($CI->smarty, TRUE); } } }
Code in "libraries/Smarty.php" Class
class CI_Smarty extends Smarty { public $template_ext = '.php'; public function __construct() { parent::__construct(); // Store the Codeigniter super global instance... whatever $CI = get_instance(); // Load the Smarty config file $CI->load->config('smarty'); // Turn on/off debug $this->debugging = $CI->config->item('smarty.smarty_debug'); // Set some pretty standard Smarty directories $this->setCompileDir($CI->config->item('smarty.compile_directory')); $this->setCacheDir($CI->config->item('smarty.cache_directory')); $this->setConfigDir($CI->config->item('smarty.config_directory')); // Default template extension $this->template_ext = $CI->config->item('smarty.template_ext'); // How long to cache templates for $this->cache_lifetime = $CI->config->item('smarty.cache_lifetime'); // Disable Smarty security policy $this->disableSecurity(); // If caching is enabled, then disable force compile and enable cache if ( $CI->config->item('smarty.cache_status') === TRUE ) { $this->enable_caching(); } else { $this->disable_caching(); } // Set the error reporting level $this->error_reporting = $CI->config->item('smarty.template_error_reporting'); // This will fix various issues like filemtime errors that some people experience // The cause of this is most likely setting the error_reporting value above // This is a static function in the main Smarty class Smarty::muteExpectedErrors(); // Should let us access Codeigniter stuff in views // This means we can go for example {$this->session->userdata('item')} // just like we normally would in standard CI views $this->assign("this", $CI); } /** * Enable Caching * * Allows you to enable caching on a page by page basis * @example $this->smarty->enable_caching(); then do your parse call */ public function enable_caching() { $this->caching = 1; } /** * Disable Caching * * Allows you to disable caching on a page by page basis * @example $this->smarty->disable_caching(); then do your parse call */ public function disable_caching() { $this->caching = 0; } }
The config file "config/smarty.php"
// Smarty caching enabled by default unless explicitly set to FALSE $config['smarty.cache_status'] = FALSE; // The path to the themes // Default is implied root directory/themes/ $config['smarty.theme_path'] = APPPATH.'views/templates/'; // The default name of the theme to use (this can be overridden) $config['smarty.theme_name'] = "default"; // Cache lifetime. Default value is 3600 seconds (1 hour) Smarty's default value $config['smarty.cache_lifetime'] = 3600; // Where templates are compiled $config['smarty.compile_directory'] = APPPATH."cache/smarty/compiled/"; // Where templates are cached $config['smarty.cache_directory'] = APPPATH."cache/smarty/cached/"; // Where Smarty configs are located $config['smarty.config_directory'] = APPPATH."third_party/Smarty/configs/"; // Default extension of templates if one isn't supplied $config['smarty.template_ext'] = 'tpl'; // Error reporting level to use while processing templates $config['smarty.template_error_reporting'] = E_ALL & ~E_NOTICE; // Debug mode turned on or off (TRUE / FALSE) $config['smarty.smarty_debug'] = FALSE; // UPDATE - Allow php templates $config['smarty.allow_php_templates'] = TRUE;
Hope that can help you.
Solved my issue too. Regards
Hi,
No need to comment the line in question. To resolve this issue, check if the debug mode is turned ON or OFF.
if ($CI->smarty->debugging) { $CI->smarty->_debug->display_debug($CI->smarty, TRUE); }
This worked for me..! Thanks a lot..!!
test purpose........ A PHP Error was encountered
Severity: User Notice
Message: Undefined property: CI_Smarty::$_debug
Filename: Smarty/Smarty.class.php
Line Number: 738
Backtrace:
File: C:\xampp\htdocs\webtuts\application\third_party\Smarty\Smarty.class.php Line: 1547 Function: _error_handler
File: C:\xampp\htdocs\webtuts\application\third_party\Smarty\Smarty.class.php Line: 738 Function: trigger_error
File: C:\xampp\htdocs\webtuts\application\core\MY_Output.php Line: 26 Function: __get
File: C:\xampp\htdocs\webtuts\index.php Line: 315 Function: require_once An uncaught Exception was encountered
Type: Error
Message: Call to a member function display_debug() on null
Filename: C:\xampp\htdocs\webtuts\application\core\MY_Output.php
Line Number: 26
Backtrace:
File: C:\xampp\htdocs\webtuts\index.php Line: 315 Function: require_once