dongxun3424 2015-11-07 11:20
浏览 89

致命错误:在opencart中调用未定义的方法Loader :: library()

I have problem in opencart to start user panel to show error like this. I am install theme but show error. but by default theme is running is good.

Fatal error: Call to undefined method Loader::library() in C:\xampp\htdocs\shopify\catalog\controller\journal2\settings.php on line 20

and code is setting.php file is

<?php
class ControllerJournal2Settings extends Controller {

private static $CACHEABLE = null;

private $css_settings = array();
private $js_settings = array();

protected $data = array();

protected function render() {
    return Front::$IS_OC2 ? $this->load->view($this->template, $this->data) : parent::render();
}

public function index() {
    $this->load->model('journal2/db');
    $this->load->model('tool/image');

    // admin mode
    $this->load->library('user');
    $this->user = new User($this->registry);
    if ($this->user->isLogged()) {
        $this->journal2->html_classes->addClass('is-admin');
    }

    // customer
    if ($this->customer->isLogged()) {
        $this->journal2->html_classes->addClass('is-customer');
    } else {
        $this->journal2->html_classes->addClass('is-guest');
    }

    // get current store config settings
    $db_config_settings = $this->model_journal2_db->getConfigSettings();
    foreach ($db_config_settings as $key => $value) {
        $this->journal2->settings->set('config_' . $key, $value);
    }

    // get active skin
    $skin_id = $this->journal2->settings->get('config_active_skin', 1);

    if (!$this->model_journal2_db->skinExists($skin_id)) {
        $skin_id = 1;
    }

how to solve it. please help.

  • 写回答

4条回答 默认 最新

  • doujiu1447 2015-11-17 00:15
    关注

    I had the same problem, having tried Journal 2.3, 2.4.8 and 2.5.5; all with opencart 2.1.0.

    Thank to this tutorial: http://code.tutsplus.com/tutorials/understand-registry-and-loader-objects-in-opencart--cms-23702

    I noticed there was no function definition for library to call $this->load->library(); so I defined my as show below:

        public function library($library) {
            $file = DIR_SYSTEM . 'library/' . str_replace('../', '', (string)$library) . '.php';
    
            if (file_exists($file)) {
                include_once($file);
            } else {
                trigger_error('Error: Could not load library ' . $file . '!');
                exit();
            }
        }
    

    It worked for me, you may try it too.

    评论

报告相同问题?