title: Developing for Mobile Devices
body: <p>This is a hot topic in this days and I need to build a template based on jQuery Mobile for my site. Build the template isn't the problem but show when someone navigate trough mobile devices is. I know I need to change some codes in OC core in order to do that but need some advice or help on this. First the place where the template is loaded is /system/engine/controller.php. This is the function:</p>
  
  <pre><code>    protected function render() {
        foreach ($this-&gt;children as $child) {
           $this -&gt; data[basename($child)] = $this -&gt; getChild($child);
        }
  
        if (file_exists(DIR_TEMPLATE . $this -&gt; template)) {
           extract($this -&gt; data);
           ob_start();
           require (DIR_TEMPLATE . $this -&gt; template);
           $this -&gt; output = ob_get_contents();
           ob_end_clean();
           return $this -&gt; output;
        } else {
           exit('Error: Could not load template ' . DIR_TEMPLATE . $this -&gt; template . '!');
        }
     }
  </code></pre>
  
  <p>Ok, I manage in how to deal to check if User Agent is Mobile Device or not and this is the result:</p>
  
  <pre><code> protected function render() {
        foreach ($this-&gt;children as $child) {
           $this -&gt; data[basename($child)] = $this -&gt; getChild($child);
        }
  
        //--------- ADDED -------------------------------------------------
        if ($this -&gt; config -&gt; get('mobile_status') == 1) {
           if (($this -&gt; isMobile() &amp;&amp; $this -&gt; config -&gt; get('autodetect') == 'true') || $this -&gt; session -&gt; data['ismobile'] == 1) {
              $mobile_template = $this -&gt; config -&gt; get('mobile_template_name');
              if ($mobile_template != '') {
                 if (!function_exists('is_dir') || (function_exists('is_dir') &amp;&amp; is_dir(DIR_TEMPLATE . $mobile_template))) {
                    $this -&gt; template = $mobile_template . "/";
                 }
              }
           }
        }
        //--------- ADDED -------------------------------------------------
  
        if (file_exists(DIR_TEMPLATE . $this -&gt; template)) {
           extract($this -&gt; data);
           ob_start();
           require (DIR_TEMPLATE . $this -&gt; template);
           $this -&gt; output = ob_get_contents();
           ob_end_clean();
           return $this -&gt; output;
        } else {
           exit('Error: Could not load template ' . DIR_TEMPLATE . $this -&gt; template . '!');
        }
     }
  </code></pre>
  
  <p>Now when I try to acces using a Mobile User Agent I get this error:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>But surprise the directory exists and it's readable, any help on this? What I'm doing wrong?
  Cheers one more time</p>
  
  <p>PS: Coming from this topic posted here <a href="http://forum.opencart.com/viewtopic.php?f=20&amp;t=47124" rel="nofollow">http://forum.opencart.com/viewtopic.php?f=20&amp;t=47124</a> </p>