Codeigniterを使用してViewページに含めるには、Controllerから関数を呼び出す必要があります。通常、私は任意のページを開くとき、私はこのページを開くためにコントローラで$ this-> load-> view()を呼び出します。今私は、メインページにサブページを含めるが、それはビュー内の任意の機能を含めることはできません。私はこのような機能を組み込もうとしています。CodeigniterでViewページに含めるためにControllerから関数を呼び出す方法は?
<body><? include(site_url().'/login'); ?></body>
<body><? include('/login'); ?></body>
<body><? include('./login'); ?></body>
私はこのリンクhttp://localhost/ci_house/index.php/loginでページを開くことができます。私のコードを実行するためにメインページを開くと、これらのエラーが表示されます。
A PHP Error was encountered
Severity: Warning
Message: include(http://localhost/ci_house/index.php/login) [function.include]: failed to open stream: no suitable wrapper could be found
Filename: views/main.php
Line Number: 8
A PHP Error was encountered
Severity: Warning
Message: include() [function.include]: Failed opening 'http://localhost/ci_house/index.php/login' for inclusion (include_path='.;C:\php5\pear')
Filename: views/main.php
Line Number: 8
2つのビューを1ページに表示したい。ビュー/ main.phpで
function test1()
{ $data['var_for_login_view'] = 'get table1';
$this->load->view('main1',$data);
}
function test2()
{ $data['var_for_login_view'] = 'get table2';
$this->load->view('main2',$data);
}
:
私は<body>
include('main1.php');
include('main2.php');
</body>
のように見せたい
$this->load->view('test1');
$this->load->view('test2');`
が、私はCodeIgniterの中で次のように表示することができます。
ビューから別のビューを挿入しますか? – Vikk
はい、**例** 'function sh_all_post() { $ this-> load-> model( 'post_model'、 'post'); $ data ['qry_post'] = $ this-> post-> get_all_post(); $ this-> load-> view( 'sh_all_post_view'、$ data); } \tパブリック関数main() \t {\t \tの$ this - >荷重 - >ビュー( '主')。 \t} これらの機能をインデックスページにのみ表示するには、この機能を含める必要があります。インデックスページを開くと、インデックスページのこれらの機能からページを表示する必要があります。 – user572575