在CodeIgniter框架上有什么像MasterPages吗? [英] Is there anything like MasterPages on CodeIgniter Framework?

查看:126
本文介绍了在CodeIgniter框架上有什么像MasterPages吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的代码Igniter,我想知道是否有什么工作类似MasterPages在.NET。

I am new to Code Igniter and I wish to know if there is anything that works like MasterPages do on .NET.

也想知道我应该在哪里

问候,并感谢您提前

推荐答案

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

Master views aren't built into the framework. To get a similar effect you can load the subview and pass that to the master view.

控制器

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));
    }
}

主视图 / p>

Master view :

<div id="header">
</div>
<div id="content">
    <?php echo $content; ?>
</div>
<div id="footer">
</div>

为了回答你的其他问题,我将所有Javascript脚本和CSS保存在项目根目录。

To answer your other question, I keep all Javascript scripts and CSS in directories in the root of my project.

这篇关于在CodeIgniter框架上有什么像MasterPages吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆