在控制器里写显示各个view 的方法,例如,我的控制器名字是Welcome:
class Welcome extents Control
{
function index ( ) {
$this -> load -> view ( 'admin/index' ) ;
}
function top ( ) {
$this -> load -> view (’admin /top‘ ) ;
}
function menu ( ) {
$this -> load -> view (’admin /menu‘ ) ;
}
function main ( ) {
$this -> load -> view (’admin /main‘ ) ;
}
function bottom ( ) {
$this -> load -> view (’admin /bottom‘ ) ;
}
}
admin/index.php内容:
{
function index ( ) {
$this -> load -> view ( 'admin/index' ) ;
}
function top ( ) {
$this -> load -> view (’admin /top‘ ) ;
}
function menu ( ) {
$this -> load -> view (’admin /menu‘ ) ;
}
function main ( ) {
$this -> load -> view (’admin /main‘ ) ;
}
function bottom ( ) {
$this -> load -> view (’admin /bottom‘ ) ;
}
}
admin/index.php内容:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html><head><title> 在线目录后台 </title>
<meta http-equiv="Content-Type" c>
</head>
<frameset rows="60,*,27" frameborder="no" border="0" framespacing="0">
<frame src="Welcome/top" name="topFrame" scrolling="no">
<frameset rows="*" cols="0,*" name="ecc" framespacing="0" frameborder="no" border="0">
<frame src="Welcome/menu" name="mainFrame" border="0" scrolling="no">
<frame src="Welcome/main" name="rightFrame" scrolling="auto">
</frameset>
<frame src="Welcome/bottom" name="bottomFrame" scrolling="no">
</frameset>
</html>
<html><head><title> 在线目录后台 </title>
<meta http-equiv="Content-Type" c>
</head>
<frameset rows="60,*,27" frameborder="no" border="0" framespacing="0">
<frame src="Welcome/top" name="topFrame" scrolling="no">
<frameset rows="*" cols="0,*" name="ecc" framespacing="0" frameborder="no" border="0">
<frame src="Welcome/menu" name="mainFrame" border="0" scrolling="no">
<frame src="Welcome/main" name="rightFrame" scrolling="auto">
</frameset>
<frame src="Welcome/bottom" name="bottomFrame" scrolling="no">
</frameset>
</html>
转载于:https://blog.51cto.com/minren8/449145
本文介绍了一种使用控制器按需加载不同视图的方法。通过定义多个函数对应不同的视图部分(如顶部、菜单、主体和底部),可以实现页面的模块化加载。这种方式有助于提高页面加载效率并简化代码结构。


被折叠的 条评论
为什么被折叠?



