Yii

How to use a variable from another function?

陌路散爱 提交于 2020-01-06 07:27:19
问题 I want to use another variable from another function, I am tried to use the global variable, but I faild. class UploadController extends Controller { public $file;// declare my $file varable function actionIndex() { $dir = Yii::getPathOfAlias('application.uploads'); $uploaded = false; $model=new Upload(); if(isset($_POST['Upload'])) { $model->attributes=$_POST['Upload']; global $file; //use the $file varable $file=CUploadedFile::getInstance($model,'file'); //get a instance into $file varable.

Yii ajax file upload

半腔热情 提交于 2020-01-06 04:28:18
问题 I need to upload image with ajax call. But POST field with image always is empty. Part of my form: <div class="col-lg-6"> <?php echo CHtml::activeFileField($model, 'logo'); ?> <?php echo CHtml::textField('test', 'test'); ?> <?php echo CHtml::submitButton('Upload'); ?> <?php echo CHtml::ajaxSubmitButton('Upload ajax', '#');?> </div> If i click submitButton , then i have both test and logo fields - image uploaded. And if i click ajaxSubmitButton , then i have only test field, logo is empty.

Yii loading jquery multiple times

放肆的年华 提交于 2020-01-06 04:12:13
问题 I currently have a page which renders 6 partial views. The problem that I am now facing is that, because I need to set processOutput to TRUE, jquery is loaded multiple times. I tried to resolve this by adding <?php Yii::app()->clientscript->scriptMap['jquery.min.js'] = FALSE; ?> <?php Yii::app()->clientscript->scriptMap['jquery.js'] = FALSE; ?> To my partial view. The problem is, that by doing so, jquery doesn't load AT all. Anyway to resolve this so it will only load once? 回答1: Change your

why pusher works on localhost but not on a live website

こ雲淡風輕ζ 提交于 2020-01-06 04:05:14
问题 I've used Pusher API to put a simple push notification in place. I've tested everything and Pusher works on my localhost . When I put the same code on a live website, Pusher doesn't publish my message. That's interesting to note that if I push from localhost I can see the message on the live version. It seems that I have no problem subscribing to a channel, but the problem is that I cannot publish a message on the channel. This is my code: // Create pusher event $pusher=Yii::app()->pusher;

yii combining addColumnCondition in CDbCriteria

柔情痞子 提交于 2020-01-06 02:25:49
问题 I have a couple of dropdown filters in my GridView, in the search part of my model I have: if ($this->agent_primary != "") { $criteria->addColumnCondition(array('agent_type_id'=>1, 'agent.agent_id'=>$this->agent_primary)); } if ($this->agent_voice != "") { $criteria->addColumnCondition(array('agent_type_id'=>2, 'agent.agent_id'=>$this->agent_voice)); } if ($this->agent_commercial != "") { $criteria->addColumnCondition(array('agent_type_id'=>3, 'agent.agent_id'=>$this->agent_commercial)); } I

Yii widget reload via ajax

我是研究僧i 提交于 2020-01-06 02:16:27
问题 I need to reload a content of my Yii widget via AJAX every XX seconds. This is my widget code: class UserOnlineWidget extends CWidget { public function init(){ } public function run(){ $userOnline=User::getOnlineUser(); $this->render("userOnLineWidget", array('userOnline'=>$userOnline)); } } And this is the view userOnLineWidget.php: <div class="userOnline"> <h5>User Online</h5> <ul> <?php foreach($userOnline as $user) { ?> <li> <ul> <li><?php echo CHtml::link($user['username'], array('/site

Yii-User and Yii-eauth integration

一笑奈何 提交于 2020-01-05 14:57:21
问题 I am trying to put together an application using yii-user and yii-eauth extensions but I am coming up short. When I create a new webapp and install eauth I can get it to work fine so I know that I am not doing anything wrong on that end. I think the problem lies with my urls. This is a demo of what it is supposed to be like: http://nodge.ru/yii-eauth/demo/login. When someone clicks on say google it should bring you to the google sign in page but on my application I am getting a 404 error that

return CActiveDataProvider in Yii

核能气质少年 提交于 2020-01-05 10:12:36
问题 I have 4 database table: User : id, username, password Floor : id, userid, name Room : id, floor, name Student : id, room, name, active How to return CActiveDataProvider for the follow SQL command? SELECT * FROM `student` WHERE `student`.`active` = 0 AND `student`.`room` IN (SELECT `room`.`id` FROM `room` WHERE `room`.`floor` = (SELECT `floor`.`id` FROM `floor` WHERE `floor`.`userid` = $userid)) I tried: $model = Student::model()->findAllBySql("SELECT * FROM student WHERE active = 0 AND room

yii : how to redirect to different page after logged in?

旧巷老猫 提交于 2020-01-05 10:04:20
问题 Q : how to redirect to different page after logged in? status : I've custom user role and I want to redirect to different page for different user. e.g hr manager -> employee/index, account manager -> account/index. I'm using yii 1.1.xx and rights module. yii and rights module are going with green. update question's info this is the rank tbl this is user tbl If the rank is Account Manager, the web site will redirect to account/index. If the rank is HR manager, the web site will redirect to

createUrl Yii - should we call it on controller view, or doesn't matter?

烈酒焚心 提交于 2020-01-05 09:23:23
问题 Should createUrl be called on controller or in views ? It doesn't matter? Or it does matter ? Is there a rule we should follow ? Like methods that extend ccontroller should be used on controllers and so on .. ? 回答1: In View you can use this snippet. You can use this snippet everywhere. Yii::app()->createUrl(); But for me is better to define a url in controller's action, and use simply $some_url var in the view. class SomeController extends Controller { public function actionSomeAction() {