2014-03-31 72 views
0

我已經在vqmod xml文件夾中安裝background_image.xml來更改opencart中的背景圖像。這個插件完美地工作,但在標題處發出通知。vqmod背景圖像更改在opencart中拋出php通知

Notice: Undefined variable: server in C:\wamp\www\opencart\vqmod\vqcache\vq2-catalog_controller_common_header.php on line 54 

這是插件的鏈接:

http://www.opencart.com/index.php?route=extension/extension/info&extension_id=16044&filter_search=background&filter_license=0

我也試過error_reporting(0),但沒有結果。這裏的代碼vqmod\vqcache\vq2-catalog_controller_common_header.php

class ControllerCommonHeader extends Controller { 
    protected function index() { 
     $this->data['title'] = $this->document->getTitle(); 

     if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { 
      $this->data['base'] = $this->config->get('config_ssl'); 
     } else { 
      $this->data['base'] = $this->config->get('config_url'); 
     } 

     $this->data['description'] = $this->document->getDescription(); 
     $this->data['keywords'] = $this->document->getKeywords(); 
     $this->data['links'] = $this->document->getLinks(); 
     $this->data['styles'] = $this->document->getStyles(); 
     $this->data['scripts'] = $this->document->getScripts(); 
     $this->data['lang'] = $this->language->get('code'); 
     $this->data['direction'] = $this->language->get('direction'); 
     $this->data['google_analytics'] = html_entity_decode($this->config->get('config_google_analytics'), ENT_QUOTES, 'UTF-8'); 

     // Whos Online 
     if ($this->config->get('config_customer_online')) { 
      $this->load->model('tool/online'); 

      if (isset($this->request->server['REMOTE_ADDR'])) { 
       $ip = $this->request->server['REMOTE_ADDR'];  
      } else { 
       $ip = ''; 
      } 

      if (isset($this->request->server['HTTP_HOST']) && isset($this->request->server['REQUEST_URI'])) { 
       $url = 'http://' . $this->request->server['HTTP_HOST'] . $this->request->server['REQUEST_URI']; 
      } else { 
       $url = ''; 
      } 

      if (isset($this->request->server['HTTP_REFERER'])) { 
       $referer = $this->request->server['HTTP_REFERER']; 
      } else { 
       $referer = ''; 
      } 

      $this->model_tool_online->whosonline($ip, $this->customer->getId(), $url, $referer); 
     } 

       if ($this->config->get('config_position')) { 
      $this->data['position'] = $this->config->get('config_position'); 
     } else { 
      $this->data['position'] = ''; 
     } 

     if ($this->config->get('config_backgroundimage') && file_exists(DIR_IMAGE . $this->config->get('config_backgroundimage'))) { 
      $this->data['backgroundimage'] = $server . 'image/' . $this->config->get('config_backgroundimage'); 
     } else { 
      $this->data['backgroundimage'] = ''; 
     } 
     $this->language->load('common/header'); 

     if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { 
      $server = HTTPS_IMAGE; 
     } else { 
      $server = HTTP_IMAGE; 
     } 

     if ($this->config->get('config_icon') && file_exists(DIR_IMAGE . $this->config->get('config_icon'))) { 
      $this->data['icon'] = $server . $this->config->get('config_icon'); 
     } else { 
      $this->data['icon'] = ''; 
     } 

     $this->data['name'] = $this->config->get('config_name'); 

     if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) { 
      $this->data['logo'] = $server . $this->config->get('config_logo'); 
     } else { 
      $this->data['logo'] = ''; 
     } 

     $this->data['text_home'] = $this->language->get('text_home'); 
     $this->data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0)); 
     $this->data['text_shopping_cart'] = $this->language->get('text_shopping_cart'); 
     $this->data['text_search'] = $this->language->get('text_search'); 
     $this->data['text_welcome'] = sprintf($this->language->get('text_welcome'), $this->url->link('account/login', '', 'SSL'), $this->url->link('account/register', '', 'SSL')); 
     $this->data['text_logged'] = sprintf($this->language->get('text_logged'), $this->url->link('account/account', '', 'SSL'), $this->customer->getFirstName(), $this->url->link('account/logout', '', 'SSL')); 
     $this->data['text_account'] = $this->language->get('text_account'); 
     $this->data['text_checkout'] = $this->language->get('text_checkout'); 

     $this->data['home'] = $this->url->link('common/home'); 
     $this->data['wishlist'] = $this->url->link('account/wishlist', '', 'SSL'); 
     $this->data['logged'] = $this->customer->isLogged(); 
     $this->data['account'] = $this->url->link('account/account', '', 'SSL'); 
     $this->data['shopping_cart'] = $this->url->link('checkout/cart'); 
     $this->data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL'); 

     if (isset($this->request->get['filter_name'])) { 
      $this->data['filter_name'] = $this->request->get['filter_name']; 
     } else { 
      $this->data['filter_name'] = ''; 
     } 

     // Menu 
     $this->load->model('catalog/category'); 

     $this->load->model('catalog/product'); 

     $this->data['categories'] = array(); 

     $categories = array(); 

     foreach ($categories as $category) { 
      if ($category['top']) { 
       $children_data = array(); 

       $children = $this->model_catalog_category->getCategories($category['category_id']); 

       foreach ($children as $child) { 
        $data = array(
         'filter_category_id' => $child['category_id'], 
         'filter_sub_category' => true 
        ); 

        $product_total = $this->model_catalog_product->getTotalProducts($data); 

        $children_data[] = array(
         'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''), 
         'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']) 
        );      
       } 

       // Level 1 
       $this->data['categories'][] = array(
        'name'  => $category['name'], 
        'children' => $children_data, 
        'column' => $category['column'] ? $category['column'] : 1, 
        'href'  => $this->url->link('product/category', 'path=' . $category['category_id']) 
       ); 
      } 
     } 

     $this->children = array(
      'module/language', 
'module/supermenu', 
      'module/supermenu_settings', 
      'module/currency', 
      'module/cart' 
     ); 

$this->data['categories'] = array(); 
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) { 
      $this->template = $this->config->get('config_template') . '/template/common/header.tpl'; 
     } else { 
      $this->template = 'default/template/common/header.tpl'; 
     } 

     $this->render(); 
    } 
} 

任何人都可以幫我解決這個問題嗎?

+0

'$ this-> data ['base'] = $ server;' - 這是引發錯誤的行嗎? –

+0

'$ this-> data ['backgroundimage'] = $ server。 '圖片/' 。 $ this-> config-> get('config_backgroundimage');'這行代碼會拋出錯誤,這個代碼也會在如if($ this-> config-> get('config_backgroundimage')&& file_exists(DIR_IMAGE) $這個 - > config->獲取( 'config_backgroundimage')))' – Poles

回答

1

的問題是, - 在默認Opencart的,代碼的下面行存在於catalog/controller/common/header.php(第6行)的begginning:

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { 
     $server = $this->config->get('config_ssl'); 
    } else { 
     $server = $this->config->get('config_url'); 
    } 

在你的情況上面的行代碼得到去除。請檢查文件vqmod\vqcache\vq2-catalog_controller_common_header.php並進行必要的更改以恢復上述代碼行。如果您使用的是更多vqmod文件,請檢查它們。

一個簡單的辦法是改變(可能在你的XML文件):

$this->data['backgroundimage'] = $server . 'image/' . $this->config->get('config_backgroundimage');

$這個 - >數據[ '和backgroundImage'] = $這個 - >數據[」基地']。 '圖片/' 。 $這個 - > config->獲取( 'config_backgroundimage');

祝您有美好的一天!

+0

抱歉地通知您,在這兩個文件我的意思是 'vqmod \ vqcache \ VQ2-catalog_controller_common_header.php'和 '目錄存在上面的代碼/控制器/ common/header.php' – Poles

+0

你可以用'vqmod \ vqcache \ vq2-catalog_controller_common_header.php'開始的代碼更新問題到'if($ this-> config-> get('config_backgroundimage') && file_exists(DIR_IMAGE。$ this-> config-> get('config_backgroundimage'))'。 –

+1

2注意事項:1.我提到的代碼不存在於您粘貼的代碼中。 server'變量在使用之前使用。 –