当我从模块中点击保存按钮时,无法找到重定向页面。

问题描述 投票:3回答:1

页面重定向找不到!当我在管理OpenCart 2.1.0.1中点击模块的保存按钮时,我认为,模块保存按钮代码是正确的。

我认为,模块保存按钮的代码是正确的,但是,在这里,我不明白,我的自定义模块的问题是什么。我已经仔细检查过了,请看下面的截图。

请看下面的截图,当我在管理中点击模块的保存按钮时。所以,它确实会重定向到 "你所请求的页面无法找到!"前面,但是,页面的URL仍然是admin。

enter image description here

我的管理模块控制器文件代码

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

    public function index() {   

      $language = $this->load->language('module/mytheme');
        $data = array_merge($language);


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

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

        $this->load->model('tool/image'); 

      if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
         $this->model_setting_setting->editSetting('mytheme', $this->request->post);

         $this->session->data['success'] = $this->language->get('text_success');

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


            $data['text_image_manager'] = 'Image manager';
            $data['token'] = $this->session->data['token'];       

        $text_strings = array(
                'heading_title',
                'text_enabled',
                'text_disabled',
                'text_content_top',
                'text_content_bottom',
                'text_column_left',
                'text_column_right',
                'entry_status',
                'entry_sort_order',
                'button_save',
                'button_cancel',

        );

        foreach ($text_strings as $text) {
            $data[$text] = $this->language->get($text);
        }


        // store config data

        $config_data = array(

        //Status
      'mytheme_status',
      'mytheme_skin',

      //Body Background
        'mytheme_background_color',
        'mytheme_button_color',
        'mytheme_button_hover_color',
        'mytheme_button_text_color',
        );

        foreach ($config_data as $conf) {
            if (isset($this->request->post[$conf])) {
                $data[$conf] = $this->request->post[$conf];
            } else {
                $data[$conf] = $this->config->get($conf);
            }
        }

        if (isset($this->error['warning'])) {
            $data['error_warning'] = $this->error['warning'];
        } else {
            $data['error_warning'] = '';
        }

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

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

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

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

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

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


        if (isset($this->request->post['mytheme_module'])) {
            $modules = explode(',', $this->request->post['mytheme_module']);
        } elseif ($this->config->get('mytheme_module') != '') {
            $modules = explode(',', $this->config->get('mytheme_module'));
        } else {
            $modules = array();
        }           


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

      $this->load->model('localisation/language');

      $data['languages'] = $this->model_localisation_language->getLanguages();


        $data['modules'] = $modules;

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

      }

      $data['mytheme_modules'] = array();

      $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->load->view('module/mytheme.tpl', $data));

    }


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

      return !$this->error;
   }
}

可能是什么原因呢,有什么线索吗?

php opencart opencart2.x opencart-module
1个回答
0
投票

经常有一个问题 & 但从你的截图来看,似乎已经没有问题了,所以一切看起来都很好,但你可能改变了管理员的URL名称,所以在 "admin "中显示 "NOT FOUND "页面。

所以一切看起来都很好,但你可能已经改变了管理员的URL名称,所以它在 "admin "中显示 "NOT FOUND "页面。

© www.soinside.com 2019 - 2024. All rights reserved.