Once you are completed with the "Creating First Yii Application", the following can be done.
$this->pageTitle=Yii::app()->name; <h1> Welcome, <?php echo Yii::app()->user->name; ! </h1> <?php // ON TAB 1: THIS IS STATIC CONTENT THAT IS TO BE DISPLAYED $Content1 = 'This is content that is to be displayed on tab 1'; // ON TAB 2: DISPLAY THE USER LIST WHICH IS THE SAME AS THE OUTPUT OF // index.php?r=user/list // GET THE DATA FOR USE BY THE TAB PAGE VIEW WHEN GENERATING THE OUTPUT $userList=User::model()->findAll(); // ??? should this be moved into the site controller??? // DATA ATTACHED TO THE $viewData IS PASSED IN TO THE CTabView // WHERE THE VIEW FOR THE TAB PAGE CAN USE IT TO GENERATE THEIR OUTPUT $viewData = array ( 'userList'=>$userList ); // ** I GOT STUCK HERE FOR A WHILE... // FOR TAB2, VIEW SPECIFICATION, MUST HAVE LEADING "/" OTHERWISE // Yii WILL LOOK FOR THE VIEW FILE UNDER THE site INSTEAD OF user $Tabs = array ( 'tab1'=>array('title'=>'Tab 1 Title','content'=>$Content1), 'tab2'=>array('title'=>'Tab 2 Title','view'=>'/user/list'), ); // THERE ARE EXAMPLE CODE WHERE THE Widget() CAN INCORPORATE // THE $viewData and $Tabs VALUES DIRECTLY BUT THIS IS EASIER TO UNDERSTAND.... $this->widget('CTabView', array('tabs'=>$Tabs, 'viewData'=>$viewData));
You will notice that on tab 2, the 'New User' and the 'Manage User' links don't work.
To fix that, edit the ...\protected\views\user\list.php file. edit lines 4 and 5. Add 'user/' in front of 'create' and 'admin'.
[<?php echo CHtml::link('New User',array('user/create')); ?>] [<?php echo CHtml::link('Manage User',array('user/admin')); ?>]
(thanks to horizons) edit line 13 to
echo CHtml::link($model->id,array('user/show','id'=>$model->id));
Total 1 comment
really, what is this wiki all about?!
Leave a comment
Please login to leave your comment.