我正在使用 Opencart 版本 2.0.1.0
I am using Opencart Version 2.0.1.0
我必须在 Opencart 中创建新页面。但我不知道如何开始。所以我按照给定的 link
https://forum.opencart.com/viewtopic.php?f=23&t=136937
但是我得到了错误
注意:间接修改重载的属性ControllerInformationStatic::$data在E:\xampp\htdocs\iraba\catalog\controller\information\static.php on line 10
无效
注意:间接修改重载的属性ControllerInformationStatic::$data在第12行
的E:\xampp\htdocs\iraba\catalog\controller\information\static.php中无效
注意:间接修改重载的属性ControllerInformationStatic::$data在E:\xampp\htdocs\iraba\catalog\controller\information\static.php on line 18
无效
注意:间接修改重载的属性 ControllerInformationStatic::$data 在第24行的E:\xampp\htdocs\iraba\catalog\controller\information\static.php中无效
致命错误:在第 41 行
的 E:\xampp\htdocs\iraba\catalog\controller\information\static.php 中调用未定义的方法 ControllerInformationStatic::render()
如link所述,我创建了三个文件分别是:
catalog/controller/information/static.php
<?php
class ControllerInformationStatic extends Controller {
private $error = array();
public function index() {
$this->language->load('information/static');
$this->document->setTitle($this->language->get('heading_title'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/static'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/static.tpl')) { //if file exists in your current template folder
$this->template = $this->config->get('config_template') . '/template/information/static.tpl'; //get it
} else {
$this->template = 'theme536/template/information/static.tpl'; //or get the file from the default folder
}
$this->children = array( //Required. The children files for the page.
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
}
?>
catalog/view/theme/theme536/template/information/static.tpl
<?php echo $header; ?>
<div class="container">
<ul class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo
$breadcrumb['text']; ?></a></li>
<?php } ?>
</ul>
<div class="row"><?php echo $column_left; ?>
<?php if ($column_left && $column_right) { ?>
<?php $class = 'col-sm-6'; ?>
<?php } elseif ($column_left || $column_right) { ?>
<?php $class = 'col-sm-9'; ?>
<?php } else { ?>
<?php $class = 'col-sm-12'; ?>
<?php } ?>
<div id="content" class="<?php echo $class; ?>"><?php echo $content_top; ?>
<h1><?php echo $heading_title; ?></h1>
YOUR OWN CONTENTS
<?php echo $content_bottom; ?></div>
<?php echo $column_right; ?></div>
</div>
<?php echo $footer; ?>
catalog/language/english/information/static.php
<?php
$_['heading_title'] = 'Static Page';
?>
您使用的一些代码已在 2+ 版本中更改。
首先,您应该将以 $this->data['...'] 开头的变量更改为 $data['...']。例如:
变化:
$this->data['breadcrumbs'] = array();
如:$data['breadcrumbs'] = array();
另外 $this->children = array(...);
版本 2+ 的用法已更改。
你应该像下面这样改变它。将此应用于所有 child 类.
$data['column_left'] = $this->load->controller('common/column_left');
最后,您应该更改响应输出。
变化:$this->response->setOutput($this->render());
如:$this->response->setOutput($this->load->view('information/static.tpl', $data));
希望对你有帮助。
我必须在 Opencart 中创建新页面。但我不知道如何开始。所以我按照给定的 link
https://forum.opencart.com/viewtopic.php?f=23&t=136937
但是我得到了错误
注意:间接修改重载的属性ControllerInformationStatic::$data在E:\xampp\htdocs\iraba\catalog\controller\information\static.php on line 10
无效注意:间接修改重载的属性ControllerInformationStatic::$data在第12行
的E:\xampp\htdocs\iraba\catalog\controller\information\static.php中无效注意:间接修改重载的属性ControllerInformationStatic::$data在E:\xampp\htdocs\iraba\catalog\controller\information\static.php on line 18
无效注意:间接修改重载的属性 ControllerInformationStatic::$data 在第24行的E:\xampp\htdocs\iraba\catalog\controller\information\static.php中无效
致命错误:在第 41 行
的 E:\xampp\htdocs\iraba\catalog\controller\information\static.php 中调用未定义的方法 ControllerInformationStatic::render()如link所述,我创建了三个文件分别是:
catalog/controller/information/static.php
<?php
class ControllerInformationStatic extends Controller {
private $error = array();
public function index() {
$this->language->load('information/static');
$this->document->setTitle($this->language->get('heading_title'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/static'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/static.tpl')) { //if file exists in your current template folder
$this->template = $this->config->get('config_template') . '/template/information/static.tpl'; //get it
} else {
$this->template = 'theme536/template/information/static.tpl'; //or get the file from the default folder
}
$this->children = array( //Required. The children files for the page.
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
}
?>
catalog/view/theme/theme536/template/information/static.tpl
<?php echo $header; ?>
<div class="container">
<ul class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo
$breadcrumb['text']; ?></a></li>
<?php } ?>
</ul>
<div class="row"><?php echo $column_left; ?>
<?php if ($column_left && $column_right) { ?>
<?php $class = 'col-sm-6'; ?>
<?php } elseif ($column_left || $column_right) { ?>
<?php $class = 'col-sm-9'; ?>
<?php } else { ?>
<?php $class = 'col-sm-12'; ?>
<?php } ?>
<div id="content" class="<?php echo $class; ?>"><?php echo $content_top; ?>
<h1><?php echo $heading_title; ?></h1>
YOUR OWN CONTENTS
<?php echo $content_bottom; ?></div>
<?php echo $column_right; ?></div>
</div>
<?php echo $footer; ?>
catalog/language/english/information/static.php
<?php
$_['heading_title'] = 'Static Page';
?>
您使用的一些代码已在 2+ 版本中更改。
首先,您应该将以 $this->data['...'] 开头的变量更改为 $data['...']。例如:
变化:
$this->data['breadcrumbs'] = array();
如:$data['breadcrumbs'] = array();
另外 $this->children = array(...);
版本 2+ 的用法已更改。
你应该像下面这样改变它。将此应用于所有 child 类.
$data['column_left'] = $this->load->controller('common/column_left');
最后,您应该更改响应输出。
变化:$this->response->setOutput($this->render());
如:$this->response->setOutput($this->load->view('information/static.tpl', $data));
希望对你有帮助。