在OpenCart 2.0中安装重写的OpenCart 1.5模块时出现500内部服务器错误

时间:2015-04-22 06:56:12

标签: php opencart

我需要在OpenCart 2上安装与OpenCart 1.5兼容的模块。安装成功但我收到以下错误:间接修改OpenCart。我试图在admin/controller/modules/mymodule.php中重写模块的代码。应用以下代码后,我在尝试编辑模块的设置时收到错误500。什么可能是错的,我错在哪里?

<?php
class ControllerModuleXDCategoryGroups extends Controller {
    private $error = array();

    public function index() {
        $this->load->language('module/XDCategoryGroups');

        $this->document->setTitle($this->language->get('heading_title'));

        $this->load->model('setting/setting');
        $this->load->model('catalog/category');

        //VALUE ASSIGNMENT
       $data=array();

        $data['heading_title'] = $this->language->get('heading_title');
        $data['error_warning'] = '';
        $data['XD_settings_title'] = $this->language->get('XD_settings_title');
        $data['text_image_manager'] = 'Upload Media';
        $data['XD_title'] = $this->language->get('XD_title');
        $data['XD_image'] = $this->language->get('XD_image');
        $data['XD_category'] = $this->language->get('XD_category');
        $data['button_save'] = $this->language->get('button_save');
        $data['button_cancel'] = $this->language->get('button_cancel');
        $data['token'] = $this->session->data['token'];

        $data['action'] = $this->url->link('module/account', 'token=' . $this->session->data['token'], 'SSL');

        $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');

        //BREADCRUMBS
        $data['breadcrumbs'] = array();

        $data['breadcrumbs'][] = array(
                'text'      => $this->language->get('text_home'),
                'href'      => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
                'separator' => false
        );

        $data['breadcrumbs'][] = array(
                'text'      => $this->language->get('text_module'),
                'href'      => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'),
                'separator' => ' :: '
        );

        $data['breadcrumbs'][] = array(
                'text'      => $this->language->get('heading_title'),
                'href'      => $this->url->link('module/google_talk', 'token=' . $this->session->data['token'], 'SSL'),
                'separator' => ' :: '
        );


        //LAYOUT OPTIONS

        $data['text_enabled'] = $this->language->get('text_enabled');
        $data['text_disabled'] = $this->language->get('text_disabled');
        $data['text_content_top'] = $this->language->get('text_content_top');
        $data['text_content_bottom'] = $this->language->get('text_content_bottom');     
        $data['text_column_left'] = $this->language->get('text_column_left');
        $data['text_column_right'] = $this->language->get('text_column_right');

        $data['entry_code'] = $this->language->get('entry_code');
        $data['entry_layout'] = $this->language->get('entry_layout');
        $data['entry_position'] = $this->language->get('entry_position');
       $data ['entry_status'] = $this->language->get('entry_status');
        $data['entry_sort_order'] = $this->language->get('entry_sort_order');

        $data['button_save'] = $this->language->get('button_save');
        $data['button_cancel'] = $this->language->get('button_cancel');
        $data['button_add_module'] = $this->language->get('button_add_module');
        $data['button_remove'] = $this->language->get('button_remove');     

        $results = $this->model_catalog_category->getCategories(0);


        //print_r($results);

        foreach ($results as $result) {


                $data['categories'][] = array(
                        'category_id' => $result['category_id'],
                   'name'        => $result['name']
                );

       }

        //SAVE OR GET LAYOUT OPTIONS
        $data['modules'] = array();     
        if (isset($this->request->post['XDCategoryGroups_module'])) {
                $data['modules'] = $this->request->post['XDCategoryGroups_module'];
        } elseif ($this->config->get('XDCategoryGroups_module')) { 
                $data['modules'] = $this->config->get('XDCategoryGroups_module');
        }

        //SAVE OR GET BLOCKS
        $data['blocks'] = array();      
        if (isset($this->request->post['XDCategoryGroupsBlocks'])) {
                $data['blocks'] = $this->request->post['XDCategoryGroupsBlocks'];
        } elseif ($this->config->get('XDCategoryGroupsBlocks')) { 
                $data['blocks'] = $this->config->get('XDCategoryGroupsBlocks');
        }

        //SAVE OR GET SETTINGS
        //SET DEFAULTS
        $data['XDSetting'] = array();
        $data['XDSetting']['categoryLimit'] = '5'; 
        $data['XDSetting']['blockHeight'] = '0'; 
        $data['XDSetting']['titlePosition'] = 'belowImage';         
        $data['XDSetting']['titleLinks'] = 'inactive';
        $data['XDSetting']['customCSSCode'] = '';
        $data['XDSetting']['blockPadding'] = '';
        $data['XDSetting']['blockPaddingLeft'] = '';
        $data['XDSetting']['blockPaddingRight'] = '';
        $data['XDSetting']['blockHeight'] = '';

        if (isset($this->request->post['XDCategoryGroupsSetting'])) {
                $data['XDSetting'] = $this->request->post['XDCategoryGroupsSetting'];
        } elseif ($this->config->get('XDCategoryGroupsSetting')) { 
                $data['XDSetting'] = $this->config->get('XDCategoryGroupsSetting');
        }

        $this->load->model('design/layout');
        $data['layouts'] = $this->model_design_layout->getLayouts();

        $this->template = 'module/XDCategoryGroups.tpl';
       /* $this->children = array(
                'common/header',
                'common/footer'
        );*/
        $data['header'] = $this->load->controller('common/header');
        $data['column_left'] = $this->load->controller('common/column_left');
        $data['footer'] = $this->load->controller('common/footer');

       $this->response->setOutput($this->render(),$data);
    //$this->response->setOutput($this->load->view($template, $data));    
}

    private function validate() {
            if (!$this->user->hasPermission('modify', 'module/XDCategoryGroups')) {
                    $this->error['warning'] = $this->language->get('error_permission');
            }

            if (!$this->error) {
                    return true;
            } else {
                    return false;
            }   
    }
}
?>

1 个答案:

答案 0 :(得分:0)

打开根文件夹中的index.php文件,并在最顶部添加以下代码:

// Enables PHP error reporting
error_reporting(E_ALL);
ini_set('display_errors', 'On');

这将启用完整的错误报告。又名这将显示确切的错误和涉及的代码行。

如果,从那里,您无法调试,请提供一些反馈,并确保包含错误消息。

相关问题