0
votes

I have to create new page in Opencart. But I don't know how to start. So I followed the given link

https://forum.opencart.com/viewtopic.php?f=23&t=136937

But I got the error

Notice: Indirect modification of overloaded property ControllerInformationStatic::$data has no effect in E:\xampp\htdocs\iraba\catalog\controller\information\static.php on line 10

Notice: Indirect modification of overloaded property ControllerInformationStatic::$data has no effect in E:\xampp\htdocs\iraba\catalog\controller\information\static.php on line 12

Notice: Indirect modification of overloaded property ControllerInformationStatic::$data has no effect in E:\xampp\htdocs\iraba\catalog\controller\information\static.php on line 18

Notice: Indirect modification of overloaded property ControllerInformationStatic::$data has no effect in E:\xampp\htdocs\iraba\catalog\controller\information\static.php on line 24

Fatal error: Call to undefined method ControllerInformationStatic::render() in E:\xampp\htdocs\iraba\catalog\controller\information\static.php on line 41

As mentioned in the link,I created three files are:

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';
?>
1
This is not the code from the link - the OpenCart 2.0 Example - you added. It's from the OpenCart 1.5 Example referenced there.makadev

1 Answers

0
votes

Some of codes you used has been changed on version 2+'s.

Firstly you should change the variables that start with $this->data['...'] as $data['...']. For example:

Change: $this->data['breadcrumbs'] = array();

As: $data['breadcrumbs'] = array();

Also $this->children = array(...); usage has been changed on version 2+'s. You should change this like below. Apply this for all child classes.

$data['column_left'] = $this->load->controller('common/column_left');

And lastly, you should change the response output.

Change: $this->response->setOutput($this->render());

As: $this->response->setOutput($this->load->view('information/static.tpl', $data));

I hope, it helps.