YiiFramework development tutorial Zii component-Tabs example
Last Update:2014-05-15
Source: Internet
Author: User
The basic usage is as follows: [php] & lt ;? Php $ this-& gt; widget (& amp; #39; zii. widgets. jui. CJuiTabs & amp; #39;, array (& amp; #39; tabs & amp; #39; & gt; array (& amp; #39; Statictab & amp; #39; & gt; & a: [php] 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,), 'htmloptions' => array ('style' => 'width: 500px; '),);?> 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,), 'htmloptions' => 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 need to be defined in SiteController: [php] public function actions () {return array ('page' => array ('class' => 'cviewaction ',), // ajaxContent action renders // "static" pages stored under 'protected/views/site/page' // They can be accessed via: // index. php? R = site/ajaxContent & view = FileName 'ajaxcontent' => array ('class' => 'application. controllers. ajaxviewaction',),);} public function actions () {return array ('page' => array ('class' => 'cviewaction ',), // ajaxContent action renders // "static" pages stored under 'protected/views/site/page' // They can be accessed via: // index. php? R = site/ajaxContent & view = FileName 'ajaxcontent' => array ('class' => 'application. controllers. ajaxviewaction',),);} where AjaxViewAction is a custom ViewAction and a subclass of CViewAction, a static page can be displayed. its definition is as follows: [php] 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, 'invalid request. please do not repeat this request again. ') ;}} 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);} elsethrow new CHttpException (400, 'invalid request. please do not repeat this request again.: