0

私はCIが初めてで、通常のHMTLファイルをテンプレートとして使用しようとしました。そこで、「application/views」に「education」という名前のフォルダーを作成しました。header.php、navigation.php、content.php、footer.php ファイルを作成しました。私が書いたコントローラーで

class Education extends CI_Controller {
 function index() {
   $this->load->view('education/header');
   $this->load->view('education/navigation');
   $this->load->view('education/content');
   $this->load->view('education/footer');
 }
}

次に、「http://localhost:8080/mvc/index.php/education/」のようなリンクにアクセスしました。

ただし、ファイルと同じフォルダーにあるスタイルシートは添付されていません。また、スタイルシート リンクの href を「echo base_url();application/views/education/style.css」に変更してみました。しかし、それもうまくいきません。

どんな助けでも

ありがとう

4

2 に答える 2

2

スタイルシート/jsファイル/画像をアプリケーションフォルダーに保持しないでください.アプリケーションフォルダーの外にある「静的」などのフォルダーに保管し、次を使用してアクセスしますbase_url()

適切なファイル/フォルダー構造は次のようになります。

website_folder/
–––– application/
–––––––– config/
–––––––––––– autoload.php
–––––––––––– config.php
–––––––––––– ...
–––––––– controllers/
–––––––––––– examples.php
–––––––––––– index.html
–––––––––––– welcome.php
–––––––– ...
–––––––– views/
––––––––---- templates/
––––––––-------- backend.php
––––––––-------- frontend.php
–––––––––––– ....
–––––––––––– example.php
–––––––––––– index.html
–––––––––––– welcome_message.php    
–––– assets/
–––––––– css/
–––––––– js/
–––––––– images/
–––––––– templates/
––––––––---- frontend/
––––––––-------- css/
––––––––-------- js/
––––––––-------- images/
––––––––---- backend/   
––––––––-------- css/
––––––––-------- js/
––––––––-------- images/
–––––––– uploads/
–––––––– index.html
–––– system/
–––– user_guide/
–––– index.php
–––– license.txt 

これこれを参照してください..

于 2012-12-28T11:35:20.177 に答える
0

ファイル: (your_site)/application/views/education/header.php

....
<LINK href="/static/some.css" rel="stylesheet" type="text/css">
....

ファイル (your_site)/static/some.css

....
 some styles
....
于 2012-12-28T11:45:37.370 に答える