2012-03-07 6 views
0

これは私の最初の質問です。私は自分のwebshopにOpencartを使っています。見た目は私のページのCSSをスタイリングしています。 account_login.css。しかし、私はまた、メンテナンスのページをしたい。私はすでにcommon_maintenance.cssファイルを作成しました。しかし、私がテストしているとき、私のサイトは正しく表示されていません。 http://www.mywebsite.com/index.php?route=common/maintenanceの代わりにhttp://www.mywebsite.comと表示されています。誰か助けてもらえますか?Opencart:CSS(経路維持に基づく)

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

URLリライティングが設定されていますか? –

+0

どのようにCSSを正確に変更していますか?これはより多くの情報を必要とします –

+0

このコードはcatalog/controller/common/header.phpにあり、行の直後に保護されたindex(){新しい行に:$ route = empty($ this-> request - > [[ルート]]を得る)? 'common/home':$ this-> request-> get ['route']; $ css_file = str_replace( '/'、 '_'、$ルート)。 '.css'; (スタイルシート/ '。$ css_file)){ $ this-> document-> addStyle(' catalog/view/theme/'$ this-> config-> get(' config_template ')。'/stylesheet/'。$ css_file); } @JayGilford – coen1234

答えて

0

私は気まぐれな書式を修正し、 - > 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()); 
     } 
    } 
} 
+0

バリーに感謝しますが、うまくいきませんでした。私は次のメッセージがあります:パースエラー:構文エラー、予期しない '}' /home/theshopspot.nl/public_html/theshopspot/catalog/controller/common/maintenance.php 56行目。この行を削除すると、次のエラー:致命的なエラー:Class 'User'が/home/theshopspot.nl/public_html/theshopspot/catalog/controller/common/maintenance.phpの15行目に見つかりませんでした。何をすべきかわかりません。私のCSSファイルの名前はcommon_maintenance.cssです。アドバイスはありますか? @BerryLangerak – coen1234

+0

@BarryLangerakそれは解決しました!私はコードを取った:$ css = 'catalog/view/theme /'。 $ this-> config-> get( 'config_template')です。 '/stylesheet/common_maintenance.css'; $ this-> document-> addStyle($ css);それを元のPHPファイルに入れました。それはトリックでした!ありがとうございます! – coen1234

+0

@ coen1234あなたの問題を解決したら、答えを受け入れるのは標準です。そしてあなたは大歓迎です:) –

0

問題は、メンテナンスモードがメンテナンスモードのときに変更されないルートを使用していることです。あなたがする必要があるのは、具体的には、$this->document->addStyle()メソッドを使用してそのスタイルシートを追加することです。

+0

私はその行をmaintenance.phpファイルに入れなければなりませんか?私は初心者だと指定してください。ありがとう – coen1234

+0

はい、あなたはそれの上にindex()メソッド内のmaintenance.phpコントローラファイルにそれを追加する必要があります –

+0

私は上記を試みたが、私はそれが非常に間違って何も動作しないと思っているよ。ここに$ this-> document-> addStyle()行のないスタイルシートがあります。どこに置くべきか教えていただけますか?common_maintenanceをどこかに入れる必要がありますか? – coen1234

関連する問題