Post by keyuri33 » Mon Sep 25, 2017 7:42 pm

I have update my theme module for OpenCart 3.0.2.0. Normally this is working fine. but, does create one minor issue. if, I does uninstall my custom theme module from admin(Extension>Extensions>Modules). though, Does not removed saved data from front side & admin side.
when, I will after again install & edit module. So, Does not remove above saved data. also, The saved data settings are not removed from the front. it does still save data.

this is working fine in older(2.3.0.2) version. But, Here, I can not judge. why this happen in latest version.
Can you please any suggestion? following code our file.

mytheme.php (admin\controller\extension\module)
<?php
class ControllerExtensionModuleMytheme extends Controller {

private $error = array();

public function index() {

$language = $this->load->language('extension/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');

if(isset($this->request->post['save_stay']) and $this->request->post['save_stay']=1)
$this->response->redirect($this->url->link('extension/module/mytheme', 'user_token=' . $this->session->data['user_token'], true));
else
$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true));

}

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

if (isset($this->session->data['success'])) {
$data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$data['success'] = '';
}

// store config data

$config_data = array(

'mytheme_background_color',
'mytheme_button_color',
'mytheme_powered_text',

);

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', 'user_token=' . $this->session->data['user_token'], true)
);

$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_extension'),
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true)
);

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


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

$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true);

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();
}

$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('extension/module/mytheme', $data));
}

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

return !$this->error;
}
}

Thanks


Newbie

Posts

Joined
Tue Aug 09, 2016 3:50 pm

Post by MarketInSG » Thu Sep 28, 2017 9:12 pm

in opencart 3, turn the twig cache off if you are doing development. that will be easier


User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore
Who is online

Users browsing this forum: No registered users and 521 guests