在CodeIgniter Framework上有类似MasterPages的东西吗?

Ger*_*son 11 php master-pages codeigniter

我是Code Igniter的新手,我想知道是否有像MasterPages那样有效的.NET.

此外,我想知道我应该在哪里保存我的公共文件,如脚本,样式和图像.

问候,并提前谢谢你

Ste*_*ran 12

主视图不会内置到框架中.要获得类似的效果,您可以加载子视图并将其传递给主视图.

控制器:

class Items extends Controller
{
    function show($id)
    {
        $item = $this->item_model->get_item($id);

        // Load the subview
        $content = $this->load->view('item/show', array('item' => $item), true);

        // Pass to the master view
        $this->load->view('master_view', array('content' => $content));
    }
}
Run Code Online (Sandbox Code Playgroud)

主视图:

<div id="header">
</div>
<div id="content">
    <?php echo $content; ?>
</div>
<div id="footer">
</div>
Run Code Online (Sandbox Code Playgroud)

要回答您的其他问题,我将所有Javascript脚本和CSS保存在项目根目录中.