2014-01-26 53 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表(以前我的布局没有以序列化的形式存储)。

希望以上也能帮助别人。

谢谢!

相关问题