質問

これは今日のホットなトピックであり、私のサイトのjQueryモバイルに基づいてテンプレートを構築する必要があります。テンプレートを構築することは問題ではありませんが、誰かがトラフモバイルデバイスをナビゲートするときに表示されます。それを行うには、OCコアのコードを変更する必要があることは知っていますが、これについてアドバイスやヘルプが必要です。まず、テンプレートがロードされている場所は/system/engine/controller.phpです。これが関数です:

    protected function render() {
      foreach ($this->children as $child) {
         $this -> data[basename($child)] = $this -> getChild($child);
      }

      if (file_exists(DIR_TEMPLATE . $this -> template)) {
         extract($this -> data);
         ob_start();
         require (DIR_TEMPLATE . $this -> template);
         $this -> output = ob_get_contents();
         ob_end_clean();
         return $this -> output;
      } else {
         exit('Error: Could not load template ' . DIR_TEMPLATE . $this -> template . '!');
      }
   }

わかりました、ユーザーエージェントがモバイルデバイスかどうかを確認するために対処する方法を管理します。これが結果です。

 protected function render() {
      foreach ($this->children as $child) {
         $this -> data[basename($child)] = $this -> getChild($child);
      }

      //--------- ADDED -------------------------------------------------
      if ($this -> config -> get('mobile_status') == 1) {
         if (($this -> isMobile() && $this -> config -> get('autodetect') == 'true') || $this -> session -> data['ismobile'] == 1) {
            $mobile_template = $this -> config -> get('mobile_template_name');
            if ($mobile_template != '') {
               if (!function_exists('is_dir') || (function_exists('is_dir') && is_dir(DIR_TEMPLATE . $mobile_template))) {
                  $this -> template = $mobile_template . "/";
               }
            }
         }
      }
      //--------- ADDED -------------------------------------------------

      if (file_exists(DIR_TEMPLATE . $this -> template)) {
         extract($this -> data);
         ob_start();
         require (DIR_TEMPLATE . $this -> template);
         $this -> output = ob_get_contents();
         ob_end_clean();
         return $this -> output;
      } else {
         exit('Error: Could not load template ' . DIR_TEMPLATE . $this -> template . '!');
      }
   }

今、私がモバイルユーザーエージェントを使用してアクセスしようとしたとき、私はこのエラーを取得します:

D: webServer htdocs portal/catalog/view/theme/libcommerce_mobile/warning:require(d: webserver htdocs portal catalog view theme libcommerce_mobile)[function.require]:オープンストリームの失敗d: webserver htdocs portal system engine controller.php on on line 77致命的なエラー:require()[function.require]:開口部の失敗 'd: webserver htdocs portal/catalog/view/view/ Theme/libcommerce_mobile/'(include_path ='。; d: webserver php pear ')in d: webserver htdocs portal system engine controller.php on 77

しかし、ディレクトリが存在することを驚かせ、読みやすい、これについての助けはありますか?私は何が間違っているのですか?もう一度乾杯

PS:ここに投稿されたこのトピックから来ています http://forum.opencart.com/viewtopic.php?f=20&t=47124

役に立ちましたか?

解決

問題は、 $this->template テンプレートディレクトリだけでなく、ファイルのパス全体が含まれています。代わりにこのようなことをする必要があります

    if($this->config->get('mobile_status') == 1) {
        if(($this->isMobile() && $this->config->get('autodetect') == 'true') || $this->session->data['ismobile'] == 1) {
            $template = preg_replace('~^[^/]+~', $this->config->get('mobile_template_name'), $this->template);
            if(file_exists(DIR_TEMPLATE . $template) && !is_dir(DIR_TEMPLATE . $template)) {
                $this->template = $template;
            }
        }
    }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top