[eluser]yusufdestina[/eluser]
I'm using Codeigniter 1.7 and HMVC (the latest release for php5).
Before I used modular extension for php4 and had no problems with it.
After upgrading my site breaks.
hook config
Code:
$hook['post_controller_constructor'][] = array('class' => 'language_hook',
'function' => 'setLanguage',
'filename' => 'language_hook.php',
'filepath' => 'hooks');
hook file
Code:
class language_hook{
var $CI;
var $sitelang = array();
var $validLanguages = array( array('code' => 'nl_BE', 'url' => 'nl', 'human' => 'nederlands'),
array('code' => 'fr_FR', 'url' => 'fr', 'human' => 'frans'),
array('code' => 'de_DE', 'url' => 'de', 'human' => 'duits'));
function __construct()
{
log_message('debug', 'Msg: Hook initialized');
}
public function setLanguage()
{
log_message('debug', 'Msg: Hook setLanguage');
$this->CI =& get_instance();
$lang = $this->CI->uri->segment(1);
$lang = strtolower($lang);
foreach($this->validLanguages as $langItem)
{
if(in_array($lang, $langItem))
{
log_message('debug', 'Msg: Hook in array');
$this->CI->sitelang['code'] = $langItem['code'];
$this->CI->sitelang['url'] = $langItem['url'];
$this->CI->sitelang['human'] = $langItem['human'];
}
}
}
}
Now in a method of my controller I can use
Code:
class Home extends Controller {
function Home()
{
parent::Controller();
$this->load->model('pages_model', 'page');
$data['pageTitle'] = "dummy";
$this->load->vars($data);
}
function index()
{
$this->lang->load('site', $this->sitelang['code']);
...
}
}
Problem is that "$this->sitelang" does not exist anymore after upgrading to modular extension for php5
I get this error:
Code:
DEBUG - 2008-11-19 15:45:28 --> Config Class Initialized
DEBUG - 2008-11-19 15:45:28 --> Hooks Class Initialized
DEBUG - 2008-11-19 15:45:28 --> URI Class Initialized
DEBUG - 2008-11-19 15:45:28 --> Router Class Initialized
DEBUG - 2008-11-19 15:45:28 --> Output Class Initialized
DEBUG - 2008-11-19 15:45:28 --> Input Class Initialized
DEBUG - 2008-11-19 15:45:28 --> XSS Filtering completed
DEBUG - 2008-11-19 15:45:28 --> Global POST and COOKIE data sanitized
DEBUG - 2008-11-19 15:45:28 --> Language Class Initialized
DEBUG - 2008-11-19 15:45:28 --> Language file loaded: language/fr_FR/frans_lang.php
DEBUG - 2008-11-19 15:45:28 --> Loader Class Initialized
DEBUG - 2008-11-19 15:45:28 --> Home Controller Initialized
DEBUG - 2008-11-19 15:45:28 --> Config file loaded: config/theme.php
DEBUG - 2008-11-19 15:45:28 --> Helper loaded: url_helper
DEBUG - 2008-11-19 15:45:28 --> Helper loaded: text_helper
DEBUG - 2008-11-19 15:45:28 --> Helper loaded: theme_helper
DEBUG - 2008-11-19 15:45:28 --> Database Driver Class Initialized
DEBUG - 2008-11-19 15:45:28 --> Session Class Initialized
DEBUG - 2008-11-19 15:45:28 --> Helper loaded: string_helper
DEBUG - 2008-11-19 15:45:28 --> Session routines successfully run
DEBUG - 2008-11-19 15:45:28 --> File loaded: C:\wamp\www\repo/system/application/models/pages_model.php
DEBUG - 2008-11-19 15:45:28 --> Model Class Initialized
ERROR - 2008-11-19 15:45:28 --> Severity: Notice --> Undefined property: Home::$sitelang C:\wamp\www\repo\system\application\controllers\home.php 43
The hook isn't executed anymore.
I've tried with pre_controller, post_controller,... no success
I hope someone can help me out
tnx for your time and help!