0

Codeigniterフレームワークを使い始めましたが、PhilSturgeonのCodeigniterテンプレートを使用したいと思います。

http://github.com/philsturgeon/codeigniter-template/zipball/master

私は以下のようなインストール手順に従いました:

  1. 最新バージョンをダウンロードする
  2. このパッケージからアプリケーションフォルダの対応するフォルダにファイルをコピーします
    • config/template(configディレクトリ内の)対応する場所にコピーします。
    • libraries/template対応する場所(ライブラリディレクトリ内)にコピーします。
    • $this->load->library('template');テンプレートの読み込み(書き込みconfig/autoload.php

そして最後に、このテンプレートをコントローラーで次のように使用します。

public function index() {
  $data["header"] = "ayastr"; 
  $data["content"] = "content1"; 
  $this->template->enable_parser(TRUE);
  $this->template->enable_parser_body(TRUE); 
  //$this->template->set('title', "test");
  $this->template->title("aya"); 
  $this->template->build('example_page_view', $data);
 }

ビューexample_page_view.phpで、私は持っているlayouts\default.php、私は書いた

{{ template:title }}

..でdefault.php。しかし、title変数にアクセスできません。私は何を間違えましたか、またはしませんでしたか?$ template ['title']を使用できるこのセクションを追加しましdefault.phpたが、変数を表示するためにパーサーを使用できません。

4

1 に答える 1

1
  1. ダウンロードしたパッケージから Template.php ファイルを libraries フォルダーにコピーします。

  2. template.php ファイルを config フォルダーにコピーします。

  3. ビュー/テンプレートの下にテンプレートがありますか

  4. 以下のように template.php (構成ファイル) を編集します。

    //Default Template Configuration (adjust this or create your own)
    //Default template - This is the Main template
    
    $template['default']['template'] = 'template/template';
    $template['default']['regions'] = array('menu','content','title');
    
    $template['default']['parser'] = 'parser';
    $template['default']['parser_method'] = 'parse';
    $template['default']['parse_template'] = TRUE;
    
    
    
    //Login Template
    $template['login']['template'] = 'template/template_login';
    $template['login']['regions'] = array('content');
    
    $template['login']['parser'] = 'parser';
    $template['login']['parser_method'] = 'parse';
    $template['login']['parse_template'] = TRUE;
    

これは基本的な構成です。ビューからデータを送信する方法について詳しく知りたい場合は、お知らせください

于 2013-03-01T12:06:48.493 に答える