0

私の ci ブログ サイトには、カテゴリと no を含む右のメニューがあります。変更の対象となる投稿の、次の形式があります。

Categories:
   Science(24)
   education(32)
    ....
    ....

括弧内の数字は、そのカテゴリの投稿の合計金額です。

私のテンプレートファイルはここにあります:

$this->load->view('includes/header');

$this->load->view($main_content);

$this->load->view('includes/footer');

そして私の右のメニューはフッターファイルにあります。どうすればこれを達成できますか?

4

2 に答える 2

0

このシステムを使用して、ヘッダー/フッターなどを含めることもできます。

<?php

/**
 * /application/core/MY_Loader.php
 *
 */
class MY_Loader extends CI_Loader {
    public function template($template_name, $vars = array(), $return = FALSE)
    {
        $content  = $this->view('templates/header', $vars, $return);
        $content .= $this->view($template_name, $vars, $return);
        $content .= $this->view('templates/footer', $vars, $return);

        if ($return)
        {
            return $content;
        }
    }
}

次に、コントローラーで行う必要があるのは次のとおりです。

<?php
$this->load->template('body');

ユーザーからの場合のコード: landons

于 2013-03-06T10:11:05.670 に答える
0

div(header、main_content、footer、right_menu) に分割されたメイン ビューを常にロードし、各ビューを適切な div にロードすることをお勧めします。

<html>
    <body>
        <div id="header">
            <?php $this->load->view('header'); ?>
        </div>
        <div id="body">
            <div id="top_menu">
                <?php $this->load->view('top_menu'); ?>
            </div>
            <div id="main_content">
                <?php $this->load->view('main_content'); ?>
            </div>
        </div>
        <div id="footer">
            <?php $this->load->view('footer'); ?>
        </div>
    </body>
</html>
于 2013-03-06T10:02:56.043 に答える