2015-11-27 159 views
2

我正在使用Opencart版本2.0.3.1。如何在Opencart中创建新页面

我必须在Opencart中创建新页面。但我不知道如何开始。所以我按照给定的链接http://forum.opencart.com/viewtopic.php?t=6253来创建自定义页面。

但我得到了错误

Fatal error: Cannot access private property Document::$title in C:\wamp\www\opencart\catalog\controller\custom\service.php on line 6

为链接提到的,我创建了三个文件是:

目录/控制器/自定义/ service.php

class ControllerCustomService extends Controller { 
    public function index() { 
     $this->language->load('custom/service'); 

     $this->document->title   = $this->language->get('heading_title'); 


     $this->document->breadcrumbs = array(); 

     $this->document->breadcrumbs[] = array(
      'href'  => $this->url->http('common/home'), 
      'text'  => $this->language->get('text_home'), 
      'separator' => FALSE 
     ); 

     $url = ''; 

     if (isset($this->request->get['page'])) { 
     $url .= '&page=' . $this->request->get['page']; 
     } 

     $this->document->breadcrumbs[] = array(
      'href'  => $this->url->http('custom/service' . $url), 
      'text'  => $this->language->get('heading_title'), 
      'separator' => $this->language->get('text_separator') 
     ); 

     $this->data['heading_title'] = $this->language->get('heading_title'); 
     $this->data['heading_text']  = $this->language->get('heading_text'); 
     $this->id     = 'content'; 
     $this->template    = $this->config->get('config_template') . 'custom/service.tpl'; 
     $this->layout    = 'common/layout'; 

     $this->render(); 
    } 
} 

目录/视图/主题/默认/模板/自定义/ service.tpl

<div class="top"> 
    <h1><?php echo $heading_title; ?></h1> 
</div> 
<div class="middle"> 
    <div><?php echo $heading_text; ?></div> 

</div> 
<div class="bottom">&nbsp;</div> 

目录/语言/自定义/ service.php

// Heading 
$_['heading_title'] = 'Our Services'; 

//Content 
$_['heading_text'] = 'Welcome to our services'; 

我也试图在链接中提到的解决方法,但没有运气。

所以有人请帮我解决这些问题...任何帮助真的是可观..

回答

2

应该$this->document->setTitle($this->language->get('heading_title'));

而引用链接是针对版本1.5.x(适用于旧版本)。您应该引用新版本的文件,然后通过引用来创建新文件。

编辑

的过程是一样的,但你必须检查语法的变化。如opencart 2.x及以上版本,它们改变了很多事物和语法。

编辑

要加载像header,footer etc共同控制器做到这一点(2.x版)

$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'); 

To load the view

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/directory/viewfile.tpl')) { 
    $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/directory/viewfile.tpl', $data)); 
} else { 
    $this->response->setOutput($this->load->view('default/template/directory/viewfile.tpl', $data)); 
} 
+0

你可以提出任何联系,在哪里可以找到相同.. – next2u

+0

我改变了控制器中的文件(有很多改变),现在它正在工作,但未能加载标题,页脚边栏,面包屑等 – next2u

+0

好的..我有链接https://forum.opencart.com/viewtopic.php?f=23&t=136937 – next2u