2014-01-26 55 views
1

我剛剛使用hostjars啓動器文件開發了我的第一個Opencart(1.5.6)插件。Opencart自定義模塊沒有顯示在前端

管理部分工作得很好,並且所有的前端代碼都被放置了。但是,由於某些原因,該模塊並未在網頁上顯示,即使該位置已在管理員中定義。

以下是參考前端控制器代碼(僅供參考,沒有錯誤拋出這讓我覺得,也許控制器不被調用或東西):

<?php class ControllerModulebevyspecials extends Controller { 
protected function index($setting) { 
    //Load the language file 
    $this->language->load('module/bevy_specials'); 

    //Load the models 
    $this->load->model('module/bevy_specials'); 

    //Get the title from the language file 
    $this->data['heading_title'] = $this->language->get('heading_title'); 

    //Retrieve Checkout Special Products 
    $products = $this->model_module_bevy_specials->getBevySpecials(); 
    if(Count($products)>0){   
     foreach ($products as $product) { 
      $product_info = $this->model_catalog_product->getProduct($product['product_id']); 
      $this->data['title'] = $product['title']; 
      if (isset($product_info)) { 
       $this->data['products'][] = array(
        'product_id' => $product_info['product_id'], 
        'name'   => $product_info['name'], 
        'discount'  => $product['discount'] 
       ); 
      } 
     } 
    } 
    else{ 
     $this->data['noRecord'] = true; 
    } 

    //Choose which template to display this module with 
    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/bevy_specials.tpl')) { 
     $this->template = $this->config->get('config_template') . '/template/module/bevy_specials.tpl'; 
    } else { 
     $this->template = 'default/template/module/bevy_specials.tpl'; 
    } 

    //Render the page with the chosen template 
    $this->render(); 
} } ?> 

我失去了任何特定的代碼顯示網頁上的模塊?

當談到模塊開發時,Opencart文檔非常少,我試過在Web上搜索解決方案,但找不到確切的答案。

任何輸入將不勝感激。提前致謝!

更多信息: 一個問題,雖然發現.....在管理面板,當我加2個或更多佈局的模塊(例如加入到「列左」的聯繫頁面和「內容頂」對於帳戶頁面),前端則顯示以下錯誤:

Warning: Invalid argument supplied for foreach() in D:\xampp171\htdocs\opencart\catalog\controller\common\column_left.php on line 49 
+0

你是否通過管理面板安裝了你的模塊? – Hassan

+0

@Hassan ....絕對是,它的安裝,配置和啓用。您可以在此處看到管理面板的快照。http://www.bevysolutions.com/stackoverflow/snap-26jan2014.jpg –

+0

您在哪裏定義了安裝/卸載方法。當你想要在opencart設置中插入它的條目時安裝模塊。你是怎麼做到的 ? 來源:http://docs.opencart.com/pages/viewpage.action?pageId=754759 – Hassan

回答

0

解決的問題 ,因爲我用的hostjars開頭的文件,我不得不修改代碼升技和問題得到了解決。

1)在模塊的管理控制器,I刪除註釋下的部分:)

"//This code handles the situation where you have multiple instances of this module, for different layouts." 

2在管理員查看.tpl文件,佈局位置,我不得不適當地格式化很少有html標籤。例如:<select name="my_module_<?php echo $module_row; ?>_layout_id">被替換爲正確的格式<select name="banner_module[<?php echo $module_row; ?>][layout_id]"> ......這確保可以在管理控制面板中保存多個佈局。 (在.tpl文件中將有8個地方需要完成)

3)最後但並非最不重要的,如果您正確執行第2步,那麼佈局將被正確序列化並保存在數據庫的oc_settings表(以前我的佈局沒有以序列化的形式存儲)。

希望以上也能幫助別人。

謝謝!

相關問題