PHP development framework YiiFramework tutorial (41) Zii component-Tabs example
The display page UI component of CJuiTabs is similar to the TabView sample function of the UI component of Yii Framework Development Tutorial (17). It encapsulates the JUI tabs plug-in.
The basic usage is as follows:
Widget ('zii. widgets. jui. CJuiTabs ', array (
'Tabs' => array (
'Static tab' => 'static content ',
'Render tab' => $ this-> renderPartial ('Pages/_ content1 ', null, true ),
'Ajax tab' => array ('Ajax '=> array ('ajaxcontent', 'View' =>' _ content2 ')),
),
'Options' => array (
'Collapsible '=> true,
'Selected' => 1,
),
'Htmlopexception' => array (
'Style' => 'width: 500px ;'
),
);?>
Three different content display methods are displayed. the Static Tab displays a Static content. the Render Tab uses Partial to Render a page, while the Ajax Tab displays a page through AJAX, note that the following two Actions must be defined in SiteController:
Public function
Actions ()
{
Return array (
'Page' => array (
'Class' => 'cviewaction ',
),
// AjaxContent action renders
// "Static" pages stored under 'protected/views/site/page'
// They can be accessed:
// Index. php? R = site/ajaxContent & view = FileName
'Ajaxcontent' => array (
'Class' => 'application. controllers. ajaxviewaction ',
),
);
} Among them, AjaxViewAction is a custom ViewAction, which is a subclass of CViewAction and can display static pages. its definition is as follows:
Class AjaxViewAction extends CViewAction
{
Private $ _ viewPath;
Public function run ()
{
If (Yii: app ()-> request-> isAjaxRequest)
{
$ This-> resolveView ($ this-> getRequestedView ());
$ Controller = $ this-> getController ();
$ Controller-> renderPartial ($ this-> view, null, false, true );
}
Else
Throw new CHttpException (400, 'invalidrequest.
Please do not repeat this request again .');
}
}
The result is as follows: