2011-11-28 8 views
1

これは今日の話題であり、自分のサイト用のjQuery Mobileに基づいたテンプレートを作成する必要があります。ビルドテンプレートは問題ではありませんが、誰かがトラフモバイルデバイスをナビゲートするときに表示されます。私はそれを行うために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 . '!'); 
     } 
    } 

[OK]を、私は、ユーザーエージェントは、モバイルデバイスがあるか、ないかどうかを確認するために対処する方法で管理し、これが結果です:私が使用してアクセスもしようとすると、今

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]: failed to open stream: Permission denied in D:\Webserver\htdocs\portal\system\engine\controller.php on line 77 Fatal error: require() [function.require]: Failed opening required 'D:\Webserver\htdocs\portal/catalog/view/theme/libcommerce_mobile/' (include_path='.;D:\Webserver\php\PEAR') in D:\Webserver\htdocs\portal\system\engine\controller.php on line 77

しかし、このディレクトリには驚きのディレクトリがあり、これは助けになりますか?私は間違っているの? 乾杯もう一回

PS:このトピックから来てここに掲載http://forum.opencart.com/viewtopic.php?f=20&t=47124

+0

'libcommerce_mobile'ディレクトリですか、それともファイルですか? –

+0

テスト用のデフォルトディレクトリのコピーですが、後でモバイル版に合わせて内容を変更しました – ReynierPM

答えて

1

問題は$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; 
      } 
     } 
    } 
+0

ありがとうございました!とにかく私は同じことをする別の方法を見つけた – ReynierPM

関連する問題