Nested Tabs

This is a description of my code. I have parent tab “General” and other parent tabs of-course. but i would like to render sub tabs in general tab. This scripts render the child tabs in parent line along with ‘general’ tab and inside general tab as well.

Very wired. Any help will be highly appreciated




[color="#2F4F4F"][code]<?php


<?php $this->beginWidget('system.web.widgets.CClipWidget', array('id'=>'General')); ?>//PARENT TAB


               //SUB TABS

                 $this->beginWidget('system.web.widgets.CClipWidget', array('id'=>'sub1')); ?>

	         child contents1

	         <?php $this->endWidget(); ?>

	

	         <?php $this->beginWidget('system.web.widgets.CClipWidget', array('id'=>'sub2')); ?>

	         child contents2

	         <?php $this->endWidget(); 


  			$tabParameters = array();

  			foreach($this->clips as $key=>$clip)

    		        $tabParameters['tab'.(count($tabParameters)+1)] = array('title'=>$key, 'content'=>$clip);

    		        $this->widget('system.web.widgets.CTabView', array('tabs'=>$tabParameters)); ?>

<?php $this->endWidget(); //PARENT TAB1

$tabParameters = array();

foreach($this->clips as $key=>$clip)

$tabParameters['tab'.(count($tabParameters)+1)] = array('title'=>$key, 'content'=>$clip);

$this->widget('system.web.widgets.CTabView', array('tabs'=>$tabParameters)); ?>




[/code][/color]

May I ask why you are using CClipWidget and CTabView?

Have you tried with CJuiTabs?

I think you don’t need to use CClipWidget. You can just create another view file to be the nested tab.

So in the main view file that contain the parent tab:




    $this->widget('CTabView', array(

        'tabs' => array(

            'generalTab' => array(

                'title' => 'General',

                'view'  => 'childTab'

            ),

            'otherParentTab' => array(

                'title'   => 'Parent Tab',

                'content' => 'This is the other parent tab content'

            ) 

        )

    ));



And then create a new view file childTab.php in the same folder which contain:




    $this->widget('CTabView', array(

        'tabs' => array(

            'childTab1' => array(

                'title'    => 'Child Tab 1',

                'content'  => 'This is the content of child tab 1'

            ),

            'childTab2' => array(

                'title'    => 'child Tab 2',

                //use 'view' => 'childTab2Content' if the content is to complex,

                //so you can create the content in a different view file (childTab2Content.php) 

                'content'  => 'This is the content of child tab 2'

            ) 

        )

    ));



Thanks very much fricky and bennouna.

I used CClipWidget because i found it very easy for me to put complex content on the tab within the same file. I dont want to have alot of view files tobe rendered in a tab. I tried CjuiTabs, but i failed to nest tabs. Thanks to trick now i have nested tabs

But one more thing Tricky_world. how can i put complex contents (contents with codes) in my tabs within same file or at least first tab.


$this->widget('CTabView', array(

        'tabs' => array(

            'generalTab' => array(

                'title' => 'General',

                'view'  => 'childTab'        //PUTING COMPLEX CONTETS HERE DIRECTLLY

            ),

            'otherParentTab' => array(

                'title'   => 'Parent Tab',

                'content' => 'This is the other parent tab content'

            ) 

        )

    ));

Just wonder, is anybody compared CjuiTabs and CTabView? And in which case it’s better to use CJuiTabs, and in which case it’s better to use CTabView?