Opencart:CSS(基于路线维护)

时间:2012-03-07 18:45:08

标签: php css opencart

这是我的第一个问题。我在网上商店使用Opencart。对于外观,我正在设计我的页面的CSS,例如account_login.css。但我也想做维护页面。我已经创建了common_maintenance.css文件。但是,当我测试我的网站时,显示不正确。它只显示http://www.mywebsite.com而不是http://www.mywebsite.com/index.php?route=common/maintenance。请有人帮我这个吗?

<?php
class ControllerCommonMaintenance extends Controller {
 public function index() {
     if ($this->config->get('config_maintenance')) {            $route = '';
                    if (isset($this->request->get['route'])) {
            $part = explode('/', $this->request->get['route']);

            if (isset($part[0])) {
                $route .= $part[0];
            }                       }
                    // Show site if logged in as admin          $this->load->library('user');
                    $this->user = new User($this->registry);
            if (($route != 'payment') && !$this->user->isLogged()) {
            return $this->forward('common/maintenance/info');           }                       
     }
 }
        public function info() {
     $this->load->language('common/maintenance');

     $this->document->setTitle($this->language->get('heading_title'));

     $this->data['heading_title'] = $this->language->get('heading_title');

     $this->document->breadcrumbs = array();

     $this->document->breadcrumbs[] = array(
         'text'      => $this->language->get('text_maintenance'),           'href'      => $this->url->link('common/maintenance'),
         'separator' => false
     ); 

     $this->data['message'] = $this->language->get('text_message');
            if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . 
 '/template/common/maintenance.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/common/maintenance.tpl';
     } else {
         $this->template = 'default/template/common/maintenance.tpl';        }
                $this->children = array(            'common/footer',            'common/header'         );

        $this->response->setOutput($this->render());
 } } ?>

2 个答案:

答案 0 :(得分:0)

问题是您正在使用路由,维护模式在维护模式下不会改变。您需要做的是使用$this->document->addStyle()方法

专门在维护控制器中添加样式表

答案 1 :(得分:0)

我修复了可怕的格式,并将调用添加到 - &gt; addStyle($ css)。如果代码还没有工作,请检查我是否有正确的CSS路径(其中显示$ css ='blahblah');

<?php
class ControllerCommonMaintenance extends Controller {
    public function index() {
        if ($this->config->get('config_maintenance')) {
            $route = '';
            if (isset($this->request->get['route'])) {
                $part = explode('/', $this->request->get['route']);
                if (isset($part[0])) {
                    $route .= $part[0];
                }
            }

            // Show site if logged in as admin
            // $this->load->library('user');
            $this->user = new User($this->registry);
            if (($route != 'payment') && !$this->user->isLogged()) {
                return $this->forward('common/maintenance/info');
            }
        }
    }

    public function info() {
        $this->load->language('common/maintenance');

        $this->document->setTitle($this->language->get('heading_title'));
        $css = 'catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/common_maintenance.css';
        $this->document->addStyle($css);
        $this->data['heading_title'] = $this->language->get('heading_title');

        $this->document->breadcrumbs = array();

        $this->document->breadcrumbs[] = array(
            'text'      => $this->language->get('text_maintenance'),
            'href'      => $this->url->link('common/maintenance'),
            'separator' => false
        );

        $this->data['message'] = $this->language->get('text_message');

        $maintenance = $this->config->get('config_template') . '/template/common/maintenance.tpl';

        if (file_exists(DIR_TEMPLATE . $maintenance ) ) {
            $this->template = $maintenance;
        }

        else {
            $this->template = 'default/template/common/maintenance.tpl';         }
            $this->children = array(
                'common/footer',
                'common/header'
            );

            $this->response->setOutput($this->render());
        }
     }
}