基于YIi的三栏frameset框架后台管理页面的实现

向大家分享一下我的后台管理页面实现,
就是那种常见的 frameset三栏布局,主要代码如下:

SiteController.php

<?php

classSiteControllerextendsCController
{
/**
* Declares class-based actions.
*/
publicfunction actions()
{
return array(
// captcha action renders the CAPTCHA image
// this is used by the contact page
‘captcha’=>array(
‘class’=>’CCaptchaAction’,
‘backColor’=>0xEBF4FB,
),
);
}

/**
* This is the default ‘index’ action that is invoked
* when an action is not explicitly requested by users.
*/
publicfunction actionIndex()
{
// renders the view file ‘protected/views/site/index.php’
// using the default layout ‘protected/views/layouts/main.php’

//注意运行yiic shell前需要改回$this->render(‘index’); 否则无法进入shell
$this->render(‘index’);
}

/**
* Displays the contact page
*/
publicfunction actionContact()
{
$contact=newContactForm;
if(isset($_POST['ContactForm']))
{
$contact->attributes=$_POST['ContactForm'];
if($contact->validate())
{
$headers=”From: {$contact->email}\r\nReply-To: {$contact->email}”;
mail(Yii::app()->params['adminEmail'],$contact->subject,$contact->body,$headers);
Yii::app()->user->setFlash(‘contact’,'Thank you for contacting us. We will respond to you as soon as possible.’);
$this->refresh();
}
}
$this->render(‘contact’,array(‘contact’=>$contact));
}

/**
* Displays the login page
*/
publicfunction actionLogin()
{
$form=newLoginForm;
// collect user input data
if(isset($_POST['LoginForm']))
{
$form->attributes=$_POST['LoginForm'];
// validate user input and redirect to previous page if valid
if($form->validate())
$this->redirect(Yii::app()->user->returnUrl);
}
// display the login form
$this->layout=’login’;
$this->render(‘login’,array(‘form’=>$form));
}

/**
* Logout the current user and redirect to homepage.
*/
publicfunction actionLogout()
{
Yii::app()->user->logout();
$this->redirect(Yii::app()->homeUrl);
}
/**
* 管理框架页
*/
publicfunction actionDefault()
{
if(Yii::app()->user->isGuest){
$this->redirect(array(‘site/login’));
}
else{
$this->renderPartial(‘default’);
}
}
/**
* 管理框架页 Head
*/
publicfunction actionHead()
{
if(Yii::app()->user->isGuest){
$this->redirect(array(‘site/login’));
}
else{
$this->renderPartial(‘head’);
}
}
/**
* 管理框架页 left
*/
publicfunction actionLeft()
{
if(Yii::app()->user->isGuest){
$this->redirect(array(‘site/login’));
}
else{
Yii::app()->getClientScript()->registerCoreScript(‘jquery’);
$this->layout=’left’;
$this->render(‘left’);
}
}
}

views/site/default.php

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>
<htmlxmlns=”http://www.w3.org/1999/xhtml”>
<head>
<metahttp-equiv=”Content-Type”content=”text/html; charset=utf-8″/>
<title></title>
</head>

<framesetrows=”92,*”cols=”*”frameborder=”no”border=”0″framespacing=”0″>
<frame src=”<?php echo Yii::app()->request->baseUrl;?>/index.php/site/head” name=”topFrame” scrolling=”no” noresize=”noresize” id=”topFrame” />
<framesetcols=”215,*”frameborder=”no”border=”0″framespacing=”0″>
<frame src=”<?php echo Yii::app()->request->baseUrl;?>/index.php/site/left” scrolling=”no” noresize=”noresize” id=”leftFrame” />
<framesrc=”"name=”mainFrame”id=”mainFrame”/>
</frameset>
</frameset>
<noframes><body>
</body>
</noframes></html>

其它相关的layout和view文件就不提供了,就是简单的html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值