3

Page redirect in cannot be found! when, I does click on save button from module in admin OpenCart 2.1.0.1.

I think, module save button code is correct. but, Here, I can not understand. what is issue in my custom module. I have double check.

Please See following screenshot. when, I do click on save button from module in admin. So, It does redirect in "The page you requested cannot be found!" front side. but, page URL is still admin.

enter image description here

My admin module Controller File code

<?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;
   }
}

What could be the reason? Any clue?

HDP
  • 4,005
  • 2
  • 36
  • 58
cwg
  • 89
  • 8

1 Answers1

1

There is often a problem with & in url encoding but it seems from your screenshot that it is already ok.

so everything looks fine, but you may have changed the name of the admin's URL so it shows the "NOT FOUND" page in "/admin".

Bhavik Hirani
  • 1,996
  • 4
  • 28
  • 46