Yii Tips Tutorials

Yii ClientScript Css, Js

CClientScript manages JavaScript and CSS stylesheets for views.CoreScriptregister New Css, Js FileMap Single ScriptMinimize Script FileDisable Js, CssInclude Js, Css Files Of Extensionsregister Style Coderegister Script codeCoreScriptregisterCoreScript method used to include the script files from core script library (From framework library) to application. So we can call the available files. Yii::app()->clientScript->registerCoreScript('jquery'); Yii::app()->clientScript->registerCoreScript('jquery.ui'); Yii::app()->clientScript->registerCoreScript('treeview'); register New Css, Js FileUsing registerCoreScript method, we can include the available files from framework. If we […]... Read More »

Yii Log

Yii Log: Logs a message into file. Every developers should know about “log” concept. It will helpful to trace error or application workflow. Yii also have “log” option. It will helpful to built wornderful yii application. LogBasic LogNew Log FileYii Trace()Log public static void log( string $msg, string $level='info', string $category='application' ) $msg - message to be logged $level - level of the message (e.g. 'trace', 'warning', 'error'). It is […]... Read More »

CKEditor In Yii Framework

Download And Install CKEditorCKEditor With YiiDownload And Install CKEditorCKEditor will helpful to create pages with large content. Normally we will use it “CMS” type of website, pages like “About Us”, “Terms and privacy”, etc . First we have to download the CKEditor using below urlhttp:&#47&#47ckeditor.com&#47downloadAfter downloaded it, We have to integrate it into our project. Extract the downloaded file. Copy and paste the ckeditor folder outside protected folder.It will place […]... Read More »

Redirect Script in Yii

When we try to load one page, we can redirect that request to another page. Yii framework support redirection method. Yii redirect function is used to redirect the one controller action to another controller action and also we can redirect within controller. The types of redirections areRedirect AnywhereRedirect Within ControllerRedirect Between ControllerRedirect Anywhere// We can redirect anywhere in application Yii::app()->request->redirect(Yii::app()->createAbsoluteUrl("user/view")); // We can redirect anywhere in application with parameter Yii::app()->request->redirect(Yii::app()->createAbsoluteUrl("user/view",array("id"=>$id))); […]... Read More »

Timestamp Behavior In Yii

Normally we will add some fields in every table of application database. Ex createdby, createdon, modifiedby, modifiedon, lasteditedby, lasteditedon etcSo we have to configure model for this action. Normally we will add beforeSave() method in every model. Instead of beforeSave in every model, We will create one behavior class and add this beforeSave method. Now we can include this behavior to every model.Create Timestamp BehaviorAdd Timestamp To ModelCreate Timestamp BehaviorI […]... Read More »

render And renderPartial In Yii

renderrenderPartialAnother Controller Viewrenderrender is used to display page with layout or theme.$this->render('login',array('model'=>$model));renderPartialThe renderPartial() method is also used for Ajax calls, where the layout isn’t appropriate It will show content of particular view file only and will not include theme files like css, js, header, footer etc.[empty theme content view]When we make a ajax request where we have to show only page body, We will use the renderPartialTo access the different […]... Read More »

Loginurl In Yii

Here i added the code to “how to set default login url in yii”config/main.php ............... 'components'=>array( 'user'=>array( 'class' => 'WebUser', 'loginUrl' => array('user/login'), ), ), .................. Read More »

Home page URL in Yii

Here i added the code to “how to set and get the home page url in yii”Set Home Page UrlGet Home Page UrlSet Home Page Url ............... 'homeUrl'=>array('user/index'), 'components'=>array( ............... ), ............... Get Home Page Url $homeurl=Yii::app()->homeUrl; //redirect home page Yii::app()->request->redirect(Yii::app()->homeUrl);... Read More »

Print Html View In Yii

Download ExtensionPrint TableDownload ExtensionUsing the below link download the extension to take the print of html [Take print What you see].Click here to download http://www.yiiframework.com/extension/mprintAfter download, Add the extension into follwoing directory “protected/extension/mPrint/mPrint”Print TableI added sample code to print the some view content <?php $this->widget('ext.mPrint.mPrint', array( 'title' => 'User Result', //the title of the document. Defaults to the HTML title 'tooltip' => 'User Result', //tooltip message of the print icon. […]... Read More »