2

Opencart バージョン 2.0.3.1を使用しています。

Opencart で新しいページを作成する必要があります。でも、どうやって始めたらいいのかわからない。そこで、指定されたリンクhttp://forum.opencart.com/viewtopic.php?t=6253に従ってカスタムページを作成しました。

しかし、私はエラーが発生しました

致命的なエラー: 6 行目の C:\wamp\www\opencart\catalog\controller\custom\service.php のプライベート プロパティ Document::$title にアクセスできません

リンクで述べたように、次の 3 つのファイルを作成しました。

カタログ/コントローラー/カスタム/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';

また、そのリンクに記載されている修正を試みましたが、うまくいきませんでした。

だから誰かが問題を解決するのを手伝ってください...どんな助けも本当にかなり..

4

1 に答える 1

3

である必要があります$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'); 

ビューをロードするには

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));
}
于 2015-11-27T06:02:38.283 に答える