2016-02-28 55 views
0

我試圖通過自定義控制器和自定義模板來列出Opencart的類別名稱和圖像該代碼是不工作上市類控制器Opencart的2不工作

控制器的文件目錄\控制器\設計\ listing.php

class ControllerDesignerListing extends Controller { 

public function index(){ 
$this->document->setTitle("Listign Designers "); 

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


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

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

foreach ($this->model_catalog_category->getCategories(array()) as $category) { 
    $this->data['categories'][] = array(
     'category_id' => $category['category_id'], 
     'name'  => $category['name'] 
    ); 
} 


$data['column_left'] = $this->load->controller('common/column_left'); 
$data['column_right'] = $this->load->controller('common/column_right'); 
$data['content_top'] = $this->load->controller('common/content_top'); 
$data['content_bottom'] = $this->load->controller('common/content_bottom'); 
$data['footer'] = $this->load->controller('common/footer'); 
$data['header'] = $this->load->controller('common/header'); 





// call the "View" to render the output 

$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/designer/listing.tpl', $data)); 

} 
} 

,這是模板文件

 <?php if($categories) { ?> 
      <?php foreach ($categories as $category) { ?> 
      <div class="col-md-3 col-sm-4 col-xs-6"><!--item--> 
       <div class="item"> 
        <div class="img-wrap"><img src="imgs/list-image.jpg" alt=""></div> 
        <div class="content"> 
         <div class="flag"><img src="imgs/flag-place.jpg" alt=""></div><a href="#"> 
          <h4><?php echo $category['name']; ?></h4></a> 
         <h5>tokyo, japan</h5><a href="#" class="line">FOLLOW</a> 
        </div> 
     </div> 
    </div> 
    <?php } ?> 
    <?php } ?> 
+0

什麼是錯誤顯示的重大變化? –

+0

提及您正在使用的opencart的版本。問題顯示opencart v2,而描述顯示在v2下面。 –

回答

0

下面是一些愚蠢的錯誤,

查找catalog\controller\designer\listing.php$this->data['categories']$data['categories']

這將工作取代。

無論何時,你從1.5.x.x版本的文件升級到Opencart的2.x.x.x,始終牢記這一點的是,這是進來Opencart的版本2.x.x.x

+0

謝謝你這個作品 –

+0

@muhammad do接受答案.. –