Archive for the ‘Yii Framework’ Category

So, plan to change themes dynamically on your page with Yii?? Here is what i do. 1. Add this code to protected/components/Controller.php public $breadcrumbs=array(); public function beforeAction($action)         {             $dynamicTheme = ‘classic’;                      if(isset($_POST['mytheme']))             {                 $dynamicTheme = $_POST['mytheme'];        [...]

If you’re running your application with php 5.2.17, there is memory leak when using active record. The solution either upgrade your php version  to 5.3 (have garbage handling) OR use DAO instead.

Php & Yii :: Read Excel File xlsx Format The basic is from here http://www.yiiframework.com/extension/phpexcel-codeplex/   Installation Download from phpexcel-codeplex Extract the release file under protected/vendors To read the excel xlsx format: Yii::import(‘application.vendors.PHPExcel’,true); $objReader = PHPExcel_IOFactory::createReader(‘Excel2007′); $objPHPExcel = $objReader->load($file); //$file –> your filepath and filename $objWorksheet = $objPHPExcel->getActiveSheet(); $highestRow = $objWorksheet->getHighestRow(); // e.g. 10 $highestColumn = $objWorksheet->getHighestColumn(); // e.g [...]

Hi, here is how you can add javascript link to your menu. Use linkOptions. $this->menu=array(    array(‘label’=>’Add New Record’, ‘url’=>array(‘create’)),        array(‘label’=>’Update Invoice NMB’, ‘url’=>’#’, ‘linkOptions’=>array(‘onclick’=>’jsFunctionHere()’)),); <script>function jsFunctionHere(){    ..do something here…}</script>

Yii::ajaxsubmitbutton – Prevent multiple post To prevent the ajaxsubmitbutton from doing multiple post, add the ‘beforeSend’ option to your code: <?php echo CHtml::ajaxSubmitButton(‘Save’,                                   array(‘formWorkHoursDays’),                                   array(                                                      ‘success’=>’function(html) { alert(html); }’,                                                      ‘beforeSend’=>’function(){                                                                        $(\’body\’).undelegate(\’#submitMe\’, \’click\’);            [...]

Yii::CGridView – Generate row number <code>$this->widget( ‘zii.widgets.grid.CGridView’, array( ‘columns’=>array( array( ‘header’=>’No.’, ‘value’=>’$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)’, ), ‘emp_no’, ‘emp_name’,  ), ));</code>

If you’ve dialog box and tab in one page… let say you have multiple form in your tab, and dialog box outside the tab..When you click a link to open the dialog box from your form, the dialog box didn’t appear.My solution, just add this piece of code at the top of your form inside [...]

1. In your gridview, modify the update button like this:       array(            ‘class’=>’CButtonColumn’,                        ‘template’=>’{update}{delete}’,                        ‘buttons’=>array(                                        ‘update’=>array(                                                      ‘url’=>’Yii::app()->createUrl(“employee/educationUpdate”, array(“id”=>$data->id))’,                                        ),                                    ),        ), 2. Then,add this javascript code:       $(‘.update’).click(function(){                 var url=$(this).attr(‘href’);                eduUpdate(url); //this function is used to open dialog box *write your own dialog box*                return false;        });

Yii vs Zend vs Code Igniter

Posted: January 7, 2011 in Php, Yii Framework

Yii vs Zend vs Code Igniter Choosing a PHP framework is not an easy task, especially if you have relatively little experience in PHP to know what makes a good framework or and what doesn’t, but choosing the right PHP framework for the job is absolutely critical in the long term as choosing the wrong [...]

Error: Yii dialog box – dialog is not a function In Controller:$this->renderPartial(‘problemDetails’,array(                         ‘modelProblem’=>$modelProblem,                        ),false,true ); Then, add this script inside your partial view. <span class=”typ”>Yii</span><span class=”pun”>::</span><span class=”pln”>app</span><span class=”pun”>()-></span><span class=”pln”>clientScript</span><span class=”pun”>-></span><span class=”pln”>scriptMap</span><span class=”pun”>=</span><span class=”pln”>array</span><span class=”pun”>(</span><span class=”pln”>          </span><span class=”com”>//scripts that you don’t need inside this view</span><span class=”pln”>         </span><span class=”str”>’jquery.js’</span><span [...]