Domanda

Questo è un tema caldo in questi giorni e ho bisogno di costruire un modello basato su jQuery Mobile per il mio sito. Costruire il modello non è il problema, ma quando un utente naviga attraverso i dispositivi mobili è. So che ho bisogno di cambiare alcuni codici a nucleo OC, al fine di farlo, ma bisogno di qualche consiglio o aiuto su questo. In primo luogo il luogo in cui viene caricato il modello è /system/engine/controller.php. Questa è la funzione:

    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, riesco a come trattare per verificare se Agente Utente Mobile Device o no e questo è il risultato:

 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 . '!');
      }
   }

Ora, quando cerco di accesso utilizzando un utente Mobile Agent ottengo questo errore:

D: \ Webserver \ htdocs \ portal / catalogo / view / theme / libcommerce_mobile / Warning: require (D: \ Webserver \ htdocs \ portal \ catalogo \ vista \ tema \ libcommerce_mobile) [function.require]: failed to open flusso: autorizzazione negata in D: \ Webserver \ htdocs \ portal \ system \ motore \ controller.php sulla linea 77 Fatal error: require () [function.require]: Failed opening required 'D: \ Webserver \ htdocs \ portal / catalogo / view / theme / libcommerce_mobile /' (include_path = '.; D: \ Webserver \ php \ PEAR') in D: \ Webserver \ htdocs \ portal \ system \ motore \ controller.php sulla linea 77

Ma a sorpresa la directory esiste ed è leggibile, qualsiasi aiuto su questo? Quello che sto facendo male? Acclamazioni ancora una volta

PS: Per chi proviene da questo argomento postato qui http: //forum.opencart. com / viewtopic.php? f = 20 & t = 47124

È stato utile?

Soluzione

Il problema è che il $this->template contiene l'intero percorso del file, non solo la directory dei modelli. Si dovrebbe fare qualcosa di simile, invece

    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;
            }
        }
    }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top