YiiFramework development tutorial Zii component-Tabs example

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.:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.