yii-components

What is wrong with the statement,in Yii?

大兔子大兔子 提交于 2019-12-11 06:58:52
问题 I have a folowing code in my controller , public function actionViewJob() { $user_id = Yii::app()->session['user_id']; /* For User Authentication */ if (Yii::app()->user->getId() === null) $this->redirect(array('site/login')); /* For User Authentication */ $model=ViewJob::model()->findAll(array('user_id'=>Yii::app()->user->id)); $params = array('model' => $model, ); $this->render('viewjob', $params); I am getting error /* Property "CDbCriteria.user_id" is not defined. */ but when I am using

Hidden Pagination summary text

∥☆過路亽.° 提交于 2019-12-08 04:55:54
问题 I use CGridView in Yii to create tables. I would like to show my table with pagination but hide the summary text at the top, which indicates the number of page restance (Displaying 1-4 of 4 results.) Is that possible? thank you Sorry for my English 回答1: There is a template option. By default it equals {summary}\n{items}\n{pager} If you override it in your gridview config, you'l be able to remove summary section: $this->widget( 'zii.widgets.CGridView', array( Your options here ... 'template' =

Yii 2.0 How to extend Core Classes

流过昼夜 提交于 2019-12-07 09:00:49
问题 I want to extend the class yii\web\Response . So I created a new class Response in the folder components and I try to overwrite the send method. namespace app\components; use Yii; class Response extends \yii\web\Response{ public function init(){ parent::init(); } /** * Sends the response to the client. */ public function send() { ... Finally I tried to import my new Response-Class by importing it in the config. $config = [ 'id' => 'basic', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'

Yii2 REST+ Angular Cross Domain CORS

大兔子大兔子 提交于 2019-12-07 03:43:39
问题 I have developed Angular & Yii2 REST service. Have problem in cross domain. Here below add my angular & Yii2 REST Code. AngularJs : (like 'http://organization1.example.com','http://organization2.example.com',....) $http.defaults.useXDomain = true; $http.defaults.withCredentials = true; $http.defaults.headers.common['Authorization'] = 'Bearer ' + MYTOKEN My Request from Angular Controller: apiURL = 'http://api.example.com'; $http.get(apiURL + '/roles') .success(function (roles) { }) .error

How to write global functions in Yii2 and access them in any view (not the custom way)

筅森魡賤 提交于 2019-12-06 20:59:57
问题 Yii1.1 had a CComponent class that had a CBaseController which was the base class for CController. There was a /protected/components/Controller.php class which enabled any function in that class to be accessed in any view. Yii2 no longer possess the CComponent class. The Yii2 guide indicates that "Yii 2.0 breaks the CComponent class in 1.1 into two classes: yii\base\Object and yii\base\Component". Does anyone know how to write global functions in Yii2 and them in any view, just like it was in

afterAjaxUpdate callbackfunction CListView shows undefined

送分小仙女□ 提交于 2019-12-06 08:27:21
问题 i am trying to call a function which is defined in another js file by afterAjaxUpdate paramter of the file name but i got error in console that function is not defined <?php $dataProvider=new CActiveDataProvider('profiles',array('pagination'=>array('pageSize'=>3))); ?> <?php $this->widget('zii.widgets.CListView', array( 'dataProvider'=>$dataProvider, 'itemView'=>'_profilesview', 'template'=>'{sorter}<br />{pager}{items}{pager}', 'enableSorting' => true, 'sortableAttributes'=>array( 'name'=>

YII compress your application output using gzip

偶尔善良 提交于 2019-12-06 07:39:14
问题 what is the benefit of below code that is two events. what its actually doing ?? require_once($yii); $app = Yii::createWebApplication($config); Yii::app()->onBeginRequest = function($event) { return ob_start("ob_gzhandler"); }; Yii::app()->onEndRequest = function($event) { return ob_end_flush(); }; $app->run(); please explain the function of this code in my application.what it does ?? and how can it help me ?? 回答1: The above code buffers the content and gzips it according to browser, rather

Yii CUserIdentity vs a User Model

做~自己de王妃 提交于 2019-12-06 07:02:40
I have at least one model in my Yii project that will need to reference a particular user ID. In my SQL for the model I have something like CONSTRAINT FOREIGN KEY (user_id) REFERENCES User(id) . I was going to go ahead and create a User model when I came across the docs for CUserIdentity. I have to admit I am confused. Is a CUserIdentity a user or a state associated with a particular user-case? I would like to use as much of the built-in Yii features as possible since they handle a lot of security-related issues from what I understand, and I am aware of the existence of some modules like srbac

yii CGridView filter with relations

拥有回忆 提交于 2019-12-06 00:57:29
I'm using yii for my web application. In one of my view I have CGridView and dataprovider is Mail model. In this model I have relation with with 3 other models. In the grid I show cols from three models. How can I filter the CGridView? UPDATE: <?php $dialog = $this->widget('ext.ecolumns.EColumnsDialog', array( 'options'=>array( 'title' => 'Layout settings', 'autoOpen' => false, 'show' => 'fade', 'hide' => 'fade', ), 'htmlOptions' => array('style' => 'display: none'), //disable flush of dialog content 'ecolumns' => array( 'gridId' => 'mails-grid', //id of related grid 'storage' => 'session', /

Yii 2.0 How to extend Core Classes

。_饼干妹妹 提交于 2019-12-05 19:29:38
I want to extend the class yii\web\Response . So I created a new class Response in the folder components and I try to overwrite the send method. namespace app\components; use Yii; class Response extends \yii\web\Response{ public function init(){ parent::init(); } /** * Sends the response to the client. */ public function send() { ... Finally I tried to import my new Response-Class by importing it in the config. $config = [ 'id' => 'basic', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'components' => [ 'import' => [ 'class' => 'app\components\Response', ], Why is it not going to work