OpenCart Blog
Languages
Menu
OpenCart Blog
OpenCart Modules
Testimonials
Support
Questions
Contact
Search
You are here
OpenCart Blog
»
Upgrading modules from OpenCart 1.5.x to OpenCart 2.0.x or changes in the OpenCart 2.0.x
Add new comment
Hello sir, how are you? i
Hello sir, how are you? i hope you are doing fine. you are genius. i have upgraded a module in opencart 2.0, the admin section is perfect, but it will not showing on the front section of the store. please help me.. The code is as given below: 1.) /admin/controller/module/eassistancepro_livechat.php <?php /* * @package eAssistance Pro Live Chat * @version 1.0 */ class ControllerModuleeassistanceprolivechat extends Controller { private $error = array(); public function index() { $this->language->load('module/eassistancepro_livechat'); $this->document->setTitle($this->language->get('heading_title')); $this->load->model('setting/setting'); if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('eassistancepro_livechat', $this->request->post); $this->session->data['success'] = $this->language->get('text_success'); //$this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL')); $this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL')); } $data['heading_title'] = $this->language->get('heading_title'); $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'); if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } if (isset($this->error['code'])) { $data['error_code'] = $this->error['code']; } else { $data['error_code'] = ''; } $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/eassistancepro_livechat', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => ' :: ' ); $data['action'] = $this->url->link('module/eassistancepro_livechat', 'token=' . $this->session->data['token'], 'SSL'); $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'); if (isset($this->request->post['eassistancepro_livechat_code'])) { $data['eassistancepro_livechat_code'] = $this->request->post['eassistancepro_livechat_code']; } else { $data['eassistancepro_livechat_code'] = $this->config->get('eassistancepro_livechat_code'); } $data['modules'] = array(); if (isset($this->request->post['eassistancepro_livechat_module'])) { $data['modules'] = $this->request->post['eassistancepro_livechat_module']; } elseif ($this->config->get('eassistancepro_livechat_module')) { $data['modules'] = $this->config->get('eassistancepro_livechat_module'); } $this->load->model('design/layout'); $data['layouts'] = $this->model_design_layout->getLayouts(); $this->template = 'module/eassistancepro_livechat.tpl'; /* $this->children = array( 'common/header', 'common/footer' ); */ $data['heading_title'] = $this->language->get('heading_title'); $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()); $this->response->setOutput($this->load->view($this->template, $data)); } protected function validate() { if (!$this->user->hasPermission('modify', 'module/eassistancepro_livechat')) { $this->error['warning'] = $this->language->get('error_permission'); } if (!$this->request->post['eassistancepro_livechat_code']) { $this->error['code'] = $this->language->get('error_code'); } if (!$this->error) { return true; } else { return false; } } } 2.) /admin/view/template/module/eassistancepro_livechat.tpl <!-- * @package eAssistance Pro Live Chat * @version 1.0 --> <?php echo $header; ?> <?php echo $column_left; ?> <div id="content"> <div class="page-header"> <div class="container-fluid"> <div class="pull-right"> <button class="btn btn-primary" title="" data-toggle="tooltip" form="form-slideshow" type="submit" data-original-title="<?php echo $button_save; ?>" onclick="$('#form').submit();"><i class="fa fa-save"></i></button> <a class="btn btn-default" title="" data-toggle="tooltip" data-original-title="<?php echo $button_cancel; ?>" href="<?php echo $cancel; ?>"><i class="fa fa-reply"></i></a> </div> <h1><?php echo $heading_title; ?></h1> <ul class="breadcrumb"> <?php foreach ($breadcrumbs as $breadcrumb) { ?> <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?> </a></li> <?php } ?> </ul> </div> </div> <div class="container-fluid"> <?php if ($error_warning) { ?> <div class="warning"> <?php echo $error_warning; ?> </div> <?php } ?> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"><i class="fa fa-pencil"></i><?php echo "Edit " . $heading_title . " Module"; ?></h3> </div> <div class="panel-body"> <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form"> <div class="well"> <div class="row"> <div class="col-sm-12"> <div class="form-group"> <label for="input-name" class="col-sm-2 control-label"><?php echo $entry_code; ?></label> <div class="col-sm-10"> <textarea name="eassistancepro_livechat_code" cols="40" rows="5" placeholder="Please enter eassistancepro chat code here" class="form-control"><?php echo $eassistancepro_livechat_code; ?></textarea> <?php if ($error_code) { ?> <span class="error"><?php echo $error_code; ?></span> <?php } ?></td> </div> </div> </div> </div> </div> <div class="table-responsive"> <table class="table table-bordered table-hover"> <thead> <tr> <td class="text-center" style="width: 1px;"> <!--<input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);">--> </td> <td class="text-left"><?php echo $entry_layout; ?></td> <td class="text-left"><?php echo $entry_position; ?></td> <td class="text-left"><?php echo $entry_status; ?></td> <td class="text-center"><?php echo $entry_sort_order; ?></td> <td class="text-center">Action</td> </tr> </thead> <?php $module_row = 0; if(count($modules) > 0) { foreach ($modules as $module) { ?> <tbody class="modulebox"> <tr id="module-row<?php echo $module_row; ?>"> <td class="text-center"></td> <td class="text-left"> <select name="eassistancepro_livechat_module[<?php echo $module_row; ?>][layout_id]"> <?php foreach ($layouts as $layout) { ?> <?php if ($layout['layout_id'] == $module['layout_id']) { ?> <option value="<?php echo $layout['layout_id']; ?>" selected="selected"> <?php echo $layout['name']; ?> </option> <?php } else { ?> <option value="<?php echo $layout['layout_id']; ?>"> <?php echo $layout['name']; ?> </option> <?php } ?> <?php } ?> </select> </td> <td class="text-left"> <select name="eassistancepro_livechat_module[<?php echo $module_row; ?>][position]"> <?php if ($module['position'] == 'content_top') { ?> <option value="content_top" selected="selected"> <?php echo $text_content_top; ?> </option> <?php } else { ?> <option value="content_top"> <?php echo $text_content_top; ?> </option> <?php } ?> <?php if ($module['position'] == 'content_bottom') { ?> <option value="content_bottom" selected="selected"> <?php echo $text_content_bottom; ?> </option> <?php } else { ?> <option value="content_bottom"> <?php echo $text_content_bottom; ?> </option> <?php } ?> <?php if ($module['position'] == 'column_left') { ?> <option value="column_left" selected="selected"> <?php echo $text_column_left; ?> </option> <?php } else { ?> <option value="column_left"> <?php echo $text_column_left; ?> </option> <?php } ?> <?php if ($module['position'] == 'column_right') { ?> <option value="column_right" selected="selected"> <?php echo $text_column_right; ?> </option> <?php } else { ?> <option value="column_right"> <?php echo $text_column_right; ?> </option> <?php } ?> </select> </td> <td class="text-left"> <select name="eassistancepro_livechat_module[<?php echo $module_row; ?>][status]"> <?php if ($module['status']) { ?> <option value="1" selected="selected"> <?php echo $text_enabled; ?> </option> <option value="0"> <?php echo $text_disabled; ?> </option> <?php } else { ?> <option value="1"> <?php echo $text_enabled; ?> </option> <option value="0" selected="selected"> <?php echo $text_disabled; ?> </option> <?php } ?> </select> </td> <td class="text-center"> <input type="text" name="eassistancepro_livechat_module[<?php echo $module_row; ?>][sort_order]" value="<?php echo $module['sort_order']; ?>" size="3" /></td> <td class="text-left"> <a onclick="$('#module-row<?php echo $module_row; ?>').remove();" class="button"><span><?php echo $button_remove; ?></span></a> </td> </tr> </tbody> <?php $module_row++; } } ?> <tfoot> <tr> <td class="text-left" colspan="5"> </td> <td class="text-left"> <a onclick="addModule();" class="button" href="javascript:;"><span><?php echo $button_add_module; ?> </span> </a> </td> </tr> </tfoot> </table> </div> </form> <div class="row"> <div class="col-sm-6 text-left"></div> <div class="col-sm-6 text-right"> </div> </div> </div> </div> </div> </div> <script type="text/javascript"> var module_row = '<?php echo $module_row; ?>'; module_row = parseInt(module_row); function addModule() { var html = '<tr id="module-row' + module_row + '">'; html += '<td class="text-left"> </td>'; html += '<td class="text-left"><select name="eassistancepro_livechat_module[' + module_row + '][layout_id]">'; <?php foreach ($layouts as $layout) { ?> html += '<option value="<?php echo $layout['layout_id']; ?>"><?php echo $layout['name']; ?></option>'; <?php } ?> html += '</select></td>'; html += '<td class="text-left"><select name="eassistancepro_livechat_module[' + module_row + '][position]">'; html += '<option value="content_top"><?php echo $text_content_top; ?></option>'; html += '<option value="content_bottom"><?php echo $text_content_bottom; ?></option>'; html += '<option value="column_left"><?php echo $text_column_left; ?></option>'; html += '<option value="column_right"><?php echo $text_column_right; ?></option>'; html += '</select></td>'; html += '<td class="text-left"><select name="eassistancepro_livechat_module[' + module_row + '][status]">'; html += '<option value="1" selected="selected"><?php echo $text_enabled; ?></option>'; html += '<option value="0"><?php echo $text_disabled; ?></option>'; html += '</select></td>'; html += '<td class="text-center"><input type="text" name="eassistancepro_livechat_module[' + module_row + '][sort_order]" value="" size="3" /></td>'; html += '<td class="text-left"><a onclick="$(\'#module-row' + module_row + '\').remove();" class="button"><span><?php echo $button_remove; ?></span></a></td>'; html += '</tr>'; $("div.table-responsive table").append(html); module_row++; } </script> <?php echo $footer; ?> 3.) /catelog/controller/module/eassistancepro_livechat.php <?php class ControllerModuleeassistanceprolivechat extends Controller { public function index() { $this->language->load('module/eassistancepro_livechat'); $data['heading_title'] = $this->language->get('heading_title'); if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $data['code'] = str_replace('http', 'https', html_entity_decode($this->config->get('eassistancepro_livechat_code'))); } else { $data['code'] = html_entity_decode($this->config->get('eassistancepro_livechat_code')); } if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/eassistancepro_livechat.tpl')) { return $this->response->setOutput($this->config->get('config_template') . '/template/module/eassistancepro_livechat.tpl', $data); } else { return $this->response->setOutput('default/template/module/eassistancepro_livechat.tpl', $data); } } } ?> 4.) /catalog/view/theme/default/template/module/eassistancepro_livechat.tpl <!-- eassistancepro.com chat code start here --> <?php echo $code; ?> <!-- eassistancepro.com chat code end here --> Thank you so much.... i think everything is right accordingly opencart2.0, but not showing the module in front of the site. please help me..
Praveen Kumar
|
Thu, 04/30/2015 - 10:08
|
Permalink
reply
Your name
Comment
*
CAPTCHA
Spam protection
Drag or click the correct shape to the grey "drop area".
You are reporting a typo in the following text:
Simply click the "Send typo report" button to complete the report. You can also include a comment.
Typo comment
Hello sir, how are you? i