我在工作中使用ASP.NET MVC3,而在家中使用PHP。我希望在CodeIgniter中使用MVC3的Sections功能,它有这样的功能吗?在ASP.NET MVC3在CodeIgniter中使用部分
实施例(未测试):
<!-- A view, that serves the content -->
@section Head{
<script src="myscript.js"></script>
}
<p>This is my main content -
I require myscript.js to be included on my page,
so I specify a head section, which the header of my page will render</p>
<!-- ANOTHER view, that serves the content -->
@section Head{
<script src="otherscript.js"></script>
<link rel="stylesheet" type="text/css" href="somestyle.css" />
}
<p>Some OTHER view, with OTHER dependencies!</p>
<!-- Header File, where I include CSS and JS! -->
<head>
<script src="jquery.js"></script>
@Html.Section("Head")
</head>
的点被,例如,在特定的视图中,我希望包括一个脚本文件,所以我添加<script>
到第,并且该部分在页眉中呈现(在不同的视图中)
为什么不使用'$ this-> load-> view('child_view_name');'在父视图中? – Tim 2012-08-13 18:33:09
你能告诉我一个如何实现我的目标的例子吗? :) – Jeff 2012-08-13 18:54:08
在我看来,你只需要将HTML的一部分添加到另一部分,对吧?如果是,那么从另一个视图加载视图看起来对我来说是个好主意。 – Tim 2012-08-13 19:13:53