Thanks Chicken’s Egg, you discovered a typo/bug in 4.2.03 language loader 😉
I’m glad I could help, allthough I found it by accident. You are amazing fast with the bugfixes wiredesignz. Thank you so much!
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
March 03, 2008 6:10pm
Subscribe [48]#526 / Jul 13, 2008 3:28am
Thanks Chicken’s Egg, you discovered a typo/bug in 4.2.03 language loader 😉
I’m glad I could help, allthough I found it by accident. You are amazing fast with the bugfixes wiredesignz. Thank you so much!
#527 / Jul 13, 2008 4:54am
I got an other fatal error.
Fatal error: Call to undefined method Modules::method() in C:\server\web\CI\edward\backend\helpers\modules_helper.php on line 210The bad news is: line 210 doesn’t exist as the modules_helper.php has got 172 lines.
To reproduce this error:
- Create a module called modules.
- Add the following line in your view-file.
<?php
// Load menu:
echo modules::run('modules', $data, 'module_list');
?>- Show this view-file loaded by an other controller. In my case the default controller is home. So I added this line in the view of ‘home’ to recieve some content of the module ‘modules’.
I thought this would call the function module_list of the module modules. But it doesn’t. And if I change the name of my module to ‘test’ it gives me an other error: “Fatal error: Cannot redeclare class Base_controller in C:\server\web\CI\edward\backend\controllers\base_controller.php on line 64”. Line 64 is nearly the last line of the class base_controller. It only contains a }-character. Line 65 contains “?>”. It’s obvious that I still have a long way to go, before I can write any modular application.
Used code
Controller - Base_controller:
<?php
class Base_controller extends Controller{
public $data = array(); // Array to store content
protected $iUrl_segment; // Segment voor menu hightlight
function __construct()
{
// Start session
session_start();
// Error reporting:
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Load controller
parent::Controller();
}
public function main_view()
{
// Show main view:
$this->load->view('main',$this->data);
}
}
?>Controller - home:
<?php
// Base Controller activeren
include(APPPATH . 'controllers/base_controller.php');
class Home extends Base_controller {
function __construct()
{
// Parent class meeladen
// Uitvoeren:
// - Hoofdmenu inbouwen
// - Standaard teksten vastleggen.
parent::__construct();
}
function index()
{
// Getting language
$this->sLanguage = $this->config->item('language'); // Taal ophalen
// Load default language file
$this->load->language('welcome',$this->sLanguage);
$this->data['content'] = '';
$this->data['sub_menu'] = '';
// Load main view
$this->main_view();
}
}Controller - test
<?php
// Base Controller activeren
include(APPPATH . 'controllers/base_controller.php');
class Test extends Base_controller{
function __construct()
{
}
function index()
{
}
function module_list()
{
echo 'test';
}
}Removing ‘extends base_controller’ from the test-controller won’t make the error to disappear.
#528 / Jul 13, 2008 5:33am
Ok, Modules is a reserved word in ME, the Modules class is inside modules_helper.php begining at line 191, so you cannot define your own Modules class also.
You are also getting “Fatal error: Cannot redeclare class Base_controller” error because you are attempting to include your Base_controller in each controller class. try using require_once instead.
#529 / Jul 13, 2008 6:37am
Ok, Modules is a reserved word in ME
If you don’t mind I will add that to the wiki aswell.
You are also getting “Fatal error: Cannot redeclare class Base_controller” error because you are attempting to include your Base_controller in each controller class. try using require_once instead.
That did the trick, I should have though of that myself. Shame on me. If you like I can create a new page on the wiki concerning this kind of problems for starters though.
#530 / Jul 13, 2008 8:14am
Yes please, anything relevant to Modular Extensions can be added to the wiki.
#531 / Jul 13, 2008 8:48am
Hey there,
got a huge problem :(
Look at this. Iam loading a module over my uri:
$module = $this->uri->segment(1, "welcome");
$method = $this->uri->segment(2, "index");
$args = array_slice($this->uri->segment_array(), 2);
$this->load->module($module);...some lines later i load the content into my template container:
$content['main'] = $this->$module->$method($args);Now when i try to load validation library inside my module controller i get an error:
Fatal error: Call to a member function set_rules() on a non-object in C:\workspace\capitalo\system\application\modules\user\controllers\user.php on line 18
Module controller is stored under:
Application
-Modules
—User
—-Controllers
——user.php
Here is the Module Controller code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
Class User extends Controller{
function __construct()
{
parent::Controller();
}
function login(){
$this->assetlib->load('mootools', 'js');
$this->assetlib->load('common', 'js');
$this->lang->load('user');
$this->load->library('validation');
$rules['user_name'] = "required";
$rules['user_pass'] = "required";
$this->validation->set_rules($rules);
if($this->validation->run() == FALSE)
return $this->load->view('login', null, TRUE);
}
function register(){
}
}
?>#532 / Jul 13, 2008 9:25am
Hey Daeli, Well I added your validation setup code to a module controller and it works fine.
You may have a non fatal error being generated before the library is loaded, which is causing it not to load properly. Try loading the library earlier and see if the error changes.
#533 / Jul 13, 2008 9:53am
I can load the library in the constructor. But not in the login function.
#534 / Jul 13, 2008 9:58am
I was able to load and run your code from both the constructor and inside a method. There may be other errors that aren’t showing up. Try turning CI logging on to its highest level and check there.
#535 / Jul 13, 2008 10:02am
Hmm no errors there…
DEBUG - 2008-07-13 15:01:19 --> Config Class Initialized
DEBUG - 2008-07-13 15:01:19 --> Hooks Class Initialized
DEBUG - 2008-07-13 15:01:19 --> URI Class Initialized
DEBUG - 2008-07-13 15:01:19 --> Router Class Initialized
DEBUG - 2008-07-13 15:01:19 --> Output Class Initialized
DEBUG - 2008-07-13 15:01:19 --> Input Class Initialized
DEBUG - 2008-07-13 15:01:19 --> Global POST and COOKIE data sanitized
DEBUG - 2008-07-13 15:01:19 --> Language Class Initialized
DEBUG - 2008-07-13 15:01:19 --> MainController Controller Initialized
DEBUG - 2008-07-13 15:01:19 --> Loader Class Initialized
DEBUG - 2008-07-13 15:01:19 --> Config file loaded: config/capitalo.php
DEBUG - 2008-07-13 15:01:19 --> Helpers loaded: url
DEBUG - 2008-07-13 15:01:19 --> Language file loaded: language/english/navigation_lang.php
DEBUG - 2008-07-13 15:01:19 --> Language file loaded: language/english/common_lang.php
DEBUG - 2008-07-13 15:01:19 --> Database Driver Class Initialized
DEBUG - 2008-07-13 15:01:19 --> Session Class Initialized
DEBUG - 2008-07-13 15:01:19 --> Helpers loaded: debug_helper
DEBUG - 2008-07-13 15:01:19 --> File loaded: C:\workspace\capitalo/system/application/modules/user/controllers/user.php
DEBUG - 2008-07-13 15:01:19 --> User Controller Initialized
DEBUG - 2008-07-13 15:01:19 --> File loaded: C:\workspace\capitalo/system/application/modules/controls/controllers/navigationcontrol.php
DEBUG - 2008-07-13 15:01:19 --> NavigationControl Controller Initialized
DEBUG - 2008-07-13 15:01:19 --> File loaded: C:\workspace\capitalo/system/application/modules/controls/controllers/usercontrol.php
DEBUG - 2008-07-13 15:01:19 --> UserControl Controller Initialized
DEBUG - 2008-07-13 15:01:19 --> Language file loaded: language/english/user_lang.php
DEBUG - 2008-07-13 15:01:19 --> Validation Class Initialized
ERROR - 2008-07-13 15:01:19 --> Severity: Notice --> Undefined property: User::$validation C:\workspace\capitalo\system\application\modules\user\controllers\user.php 15#536 / Jul 13, 2008 10:35am
Ok I see the problem, because CI assigns the last controller as the value for get_instance, and CI_Loader uses get_instance to load system libraries, validation has been assigned to usercontrol.php rather than user.php
You need to load libraries in the constructor of your module controllers to avoid this.
#537 / Jul 13, 2008 11:45am
Oh thats kinda bad you know 😊
#538 / Jul 13, 2008 12:03pm
Hé wiredesignz, I see you’ve found the new wiki-pages I made. 😊 I see you’ve also improved my code example at the FAQ-page. Sadly the new code gives me an error. “Only variable references should be returned by reference. Filename: libraries/Controller.php. Line Number: 294.” That is why I had written a TRUE behind the view and a return. Otherwise I don’t know how to display it correctly.
And it looks like you didn’t like my ‘Notices and errors’ very much. I’m sorry for that, I did my best. :down:
#539 / Jul 13, 2008 7:37pm
@Daeli, It’s due to the fact that CI prevents us altering codeigniter/Base4.php or Base5.php and uses get_instance() when loading libraires rather than passing a reference to the loader. Note: This only happens with CI system/libraries.
@Chicken’s Egg, I updated the wiki Errors page because there was information not relevant to ME, Thanks for your efforts though they are appreciated.
#540 / Jul 13, 2008 7:46pm
Modular Extensions version 4.2.05 (bugfix) is available on the wiki.
Fixed: “Only variable references should be returned by reference” error. Thanks Chicken’s Egg. 😉