我刚刚用hostjars初学者文件开发了我的第一个Opencart (1.5.6)插件。
管理部分工作得很好,所有的前端代码都已经放置好了。然而,由于某些原因,模块没有显示在网页上,即使该位置已在管理中定义。
下面是用于引用的前端控制器代码(FYI,没有抛出错误,这使我认为可能没有调用Controller或其他什么):
<?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个或更多的布局(例如添加到联系人页面的“左列”和帐户页面的“内容-顶部”)时, One问题发现了though.....in管理面板,然后前端显示以下错误:
Warning: Invalid argument supplied for foreach() in D:\xampp171\htdocs\opencart\catalog\controller\common\column_left.php on line 49
发布于 2014-01-26 10:34:00
问题解决了,因为我使用了hostjars启动文件,我不得不修改代码abit,问题得到了解决。
1)在模块的管理控制器中,我删除了注释下面的部分:
"//This code handles the situation where you have multiple instances of this module, for different layouts."
2)在Admin .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
表中(以前,我的布局没有以序列化的形式存储)。
希望上面的这些也能帮助到别人。
谢谢!
https://stackoverflow.com/questions/21360067
复制相似问题