自定义opencart管理页面不会出现

时间:2015-10-18 15:54:29

标签: php model-view-controller opencart opencart-module

我为opencart面板创建了一个自定义管理页面。如果我尝试运行route index.php?route = report / remarketing,系统将退出而不是显示页面!

这是代码:

控制器

 class ControllerReportRemarketing extends Controller {
    public function index()
    {
    $template="report/remarketing.tpl";
    $this->load->language('report/remarketing');
    $this->load->model('report/remarketing');
    $this->template = ''.$template.'';
    $this->data['record'] = 'test';

    $this->children = array(
        'common/header',
        'common/footer'
    );
    $this->response->setOutput($this->render());
   }
}

模型(没有方法)

class ModelReportRemarketing extends Model {
}

视图

<?php echo $header; ?>
   <div id="content">
      <?php echo $record; ?>
   </div>
<?php echo $footer; ?>

此外,我还在用户组中为用户设置了访问权限

1 个答案:

答案 0 :(得分:0)

我认为您使用的是旧版本的opencart代码,以下是opencart版本2.0.2.0的示例:

首先,创建&#39;再营销.php&#39;在admin \ language \ english \ report下,添加以下内容:

<?php
// Heading
$_['heading_title']    = 'Marketing Report';

其次,修改&#39; replaeting.php&#39;在admin \ controller \ report下,如下所示

<?php
class ControllerReportRemarketing extends Controller{ 
    public function index(){
        // displayed text import
        $this->load->language('report/remarketing');

        // get header and footer
        $data['breadcrumbs'] = array();
        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('text_home'),
            'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL')
        );
        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('heading_title'),
            'href' => $this->url->link('extension/feed', 'token=' . $this->session->data['token'], 'SSL')
        );
        $data['heading_title'] = $this->language->get('heading_title');
        $data['header'] = $this->load->controller('common/header');
        $data['column_left'] = $this->load->controller('common/column_left');
        $data['footer'] = $this->load->controller('common/footer');

        // the model, need not to import
        // $this->load->model('report/remarketing');

        // testing
        $data['record'] = 'test';

        $this->response->setOutput($this->load->view("report/remarketing.tpl", $data));
    }
}
?>

最后,修改&#39; remarketing.tpl&#39;在admin \ view \ template \ report

<?php echo $header; ?><?php echo $column_left; ?>
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <h1><?php echo $heading_title; ?></h1>
      <ul class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
        <?php } ?>
      </ul>
    </div>
  </div>
  <div class="container-fluid"><?php echo $record; ?></div>
</div>
<?php echo $footer; ?>