【发布时间】:2017-05-03 13:24:16
【问题描述】:
我必须在 Opencart 中创建新页面。但我不知道如何开始。所以我按照给定的链接
https://forum.opencart.com/viewtopic.php?f=23&t=136937
但我得到了错误
注意:间接修改重载属性 ControllerInformationStatic::$data 在第 10 行的 E:\xampp\htdocs\iraba\catalog\controller\information\static.php 中无效
注意:间接修改重载属性 ControllerInformationStatic::$data 在第 12 行的 E:\xampp\htdocs\iraba\catalog\controller\information\static.php 中无效
注意:间接修改重载属性 ControllerInformationStatic::$data 在第 18 行的 E:\xampp\htdocs\iraba\catalog\controller\information\static.php 中无效
注意:间接修改重载属性 ControllerInformationStatic::$data 在 E:\xampp\htdocs\iraba\catalog\controller\information\static.php 的第 24 行没有影响
致命错误:在第 41 行的 E:\xampp\htdocs\iraba\catalog\controller\information\static.php 中调用未定义的方法 ControllerInformationStatic::render()
正如链接中提到的,我创建了三个文件是:
目录/控制器/信息/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; ?>
目录/语言/english/information/static.php
<?php
$_['heading_title'] = 'Static Page';
?>
【问题讨论】:
-
这不是您添加的链接中的代码 - OpenCart 2.0 示例。它来自那里引用的 OpenCart 1.5 示例。
标签: php opencart2.x