2014-02-07 38 views
0

我正在使用opencart前端,並且我爲每個供應商提供了子域類型的結構。如果在URL中找到供應商名稱,則它作爲不同的子域名工作在opencart中找不到頁面

如果輸入的供應商名稱不存在於數據庫中,我想重定向到頁面未找到頁面。我能夠檢索到這些信息,但我不知道該在哪裏檢查,天氣在index.php頁面或home.php或其他任何地方。

我的網址是localhost/user/vendor_name。

請幫我知道我從哪裏可以重定向到not_found頁面。

+0

供應商功能由您執​​行?還是你有一些擴展? –

+0

對於管理員我已經使用多廠商擴展,但對於前端我還沒有使用任何擴展。 – saurabh

回答

0

在您的供應商檔案的前端控制器文件添加一個條件,如:

if(vendor available){ 
//Show the correct contents 
    }else{ 

     $url = ''; 

     if (isset($this->request->get['path'])) { 
      $url .= '&path=' . $this->request->get['path']; 
     } 

     if (isset($this->request->get['filter'])) { 
      $url .= '&filter=' . $this->request->get['filter']; 
     } 

     if (isset($this->request->get['sort'])) { 
      $url .= '&sort=' . $this->request->get['sort']; 
     } 

     if (isset($this->request->get['order'])) { 
      $url .= '&order=' . $this->request->get['order']; 
     } 

     if (isset($this->request->get['page'])) { 
      $url .= '&page=' . $this->request->get['page']; 
     } 

     if (isset($this->request->get['limit'])) { 
      $url .= '&limit=' . $this->request->get['limit']; 
     } 

     $this->data['breadcrumbs'][] = array(
      'text'  => $this->language->get('text_error'), 
      'href'  => $this->url->link('vendor/vendor', $url), //replace with vendor controllers 
      'separator' => $this->language->get('text_separator') 
     ); 

     $this->document->setTitle($this->language->get('text_error')); 

     $this->data['heading_title'] = $this->language->get('text_error'); 

     $this->data['text_error'] = $this->language->get('text_error'); 

     $this->data['button_continue'] = $this->language->get('button_continue'); 

     $this->data['continue'] = $this->url->link('common/home'); 

     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) { 
      $this->template = $this->config->get('config_template') . '/template/error/not_found.tpl'; 
     } else { 
      $this->template = 'default/template/error/not_found.tpl'; 
     } 

     $this->children = array(
      'common/column_left', 
      'common/column_right', 
      'common/content_top', 
      'common/content_bottom', 
      'common/footer', 
      'common/header' 
     ); 

     $this->response->setOutput($this->render()); 


} 

一個愉快的一天有!

+0

我在home.php中添加了這個條件,因爲那是被訪問的第一頁。但它使用column_right,column_left和column_top,並且我有這些佈局中的數據發生更改的條件,因此會產生大量錯誤。 請提出任何建議。 – saurabh

+0

我不知道您的供應商文件或您在家中做過的更改。此外,我堅信上述代碼不適用於家用控制器。它需要放在你檢查供應商是否存在的地方。 –