: This article mainly introduces a small suggestion about OpenCart. if you are interested in the PHP Tutorial, please refer to it. OpenCart is a well-established open-source free B2C E-commerce system.
GithubOn the project, found to be very active, every day someone feedback bugs.
Initially, it allows you to manage multiple stores in the background, and you can have different prices for the same product in different stores. different domain names can be bound between stores. This is a special feature.
However, looking at its code, we found that there have been few changes over the years, and there is no evolutionary feeling in terms of code Division.
A large amount of data, such as languages, links, and current paths, that should be constructed by views, is put in the controller,
Like the front-end login page:
$data['breadcrumbs'] = array();$data['breadcrumbs'][] = array('text' => $this->language->get('text_home'),'href' => $this->url->link('common/home'));$data['breadcrumbs'][] = array('text' => $this->language->get('text_account'),'href' => $this->url->link('account/account','','SSL'));$data['breadcrumbs'][] = array('text' => $this->language->get('text_login'),'href' => $this->url->link('account/login','','SSL'));$data['heading_title'] = $this->language->get('heading_title');$data['text_new_customer'] = $this->language->get('text_new_customer');$data['text_register'] = $this->language->get('text_register');$data['text_register_account'] = $this->language->get('text_register_account');$data['text_returning_customer'] = $this->language->get('text_returning_customer');$data['text_i_am_returning_customer'] = $this->language->get('text_i_am_returning_customer');$data['text_forgotten'] = $this->language->get('text_forgotten');$data['entry_email'] = $this->language->get('entry_email');$data['entry_password'] = $this->language->get('entry_password');$data['button_continue'] = $this->language->get('button_continue');$data['button_login'] = $this->language->get('button_login');if(isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } $data['action'] = $this->url->link('account/login','','SSL');$data['register'] = $this->url->link('account/register','','SSL');$data['forgotten'] = $this->url->link('account/forgotten','','SSL');
It is quite cumbersome. In fact, it can be placed in view files under the existing framework features.
In the header of the view file:
Registry-> get ('language'); // load the language pack Management Object $ url = $ this-> registry-> get ('URL '); // load the url object $ this-> language ('Common/footer '); // load the language pack?>
get('text_information');?>
In this way, the controller does not have to worry about such boring things, but focuses on calling the business logic and core data.
The above introduces a small suggestion about OpenCart, including github, and hopes to help those who are interested in PHP tutorials.