A small suggestion about OpenCart

Source: Internet
Author: User
Tags php foreach opencart
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.