Yii Framework Forum: How to access data variable passed in CTabView - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to access data variable passed in CTabView Rate Topic: -----

#1 User is offline   bipin000 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 14-May 12

Posted 18 July 2012 - 10:39 AM

Hi,
i am passing custom variable to each tab in CTabView but didn't get how to access that variable in the view


 $Tabs     = array
               (
                  'tab1'=>array('title'=>'one','view'=>'pages',
                      'data'=>array('position'=>'1')),
                  'tab2'=>array('title'=>'two','view'=>'pages',
                      'data'=>array('position'=>'2')),
                  'tab3'=>array('title'=>'Three','view'=>'pages',
                      'data'=>array('position'=>'3')),
               ); 
   $this->widget('CTabView', array('tabs'=>$Tabs));


How can i access position variable in my view
0

#2 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 419
  • Joined: 23-July 09

Posted 19 July 2012 - 03:06 AM

Your CTabView uses the same view 'pages.php' for each tab. You should instead have a separate view file for each page, eg. page1.php, page2.php, page3.php

The 'data' attribute 'position' can be accessed in your view file using PHP:

<?php
    echo $position;
?>

We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#3 User is offline   bipin000 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 14-May 12

Posted 19 July 2012 - 03:20 AM

i tried echoing $position but i got
Undefined variable : position

when i used different views for each it works but i found in the CTabView Google doc that data variable is only added for the same reason mean to pass a variable with different values to the same view
0

#4 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 419
  • Joined: 23-July 09

Posted 19 July 2012 - 03:30 AM

I just tested as per the code you posted. It will actually work with a single page 'pages.php' with:

<?php echo $position; ?>

We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users