Yii Framework Forum: Yii-Redactor - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii-Redactor Getting no results with the imageUpload-function Rate Topic: -----

#1 User is offline   Solid 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 60
  • Joined: 29-December 12
  • Location:Kristiansand, Norway

Posted 29 December 2012 - 07:12 PM

Hi!

Anyone got the imageUpload from the Yii-Redactor-extension to work?

I have a few questions regarding it, first off: What is the 'attribute'=>$attribute supposed to be? I just dont understand what string it would need there.

Secondly, when i just define 'attribute' => 'text' (that is the attribute for the entry in the table im using redactor for) it loads allright, but when i try to upload the image, it thinks for a short while, but no image is uploaded.

The Controller:
	public function actions()
    {
        return array(
            'imageUpload'=>array(
                'class'=>'ext.redactor.actions.ImageUpload',
                'uploadCreate'=>true,
            ),
            'imageList'=>array(
                'class'=>'ext.redactor.actions.ImageList',
            ),
        );
    }


The view:
$this->widget('bootstrap.widgets.TbBox', array(
    'title' => 'Opprett nyhet',
    'headerIcon' => 'icon-home',
    'content' => $this->renderPartial('_form', array('model'=>$model), true) // $this->renderPartial('_view')
));


The _form:
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
	'id'=>'news-form',
	'enableAjaxValidation'=>false,
)); ?>

	<?php echo $form->errorSummary($model); ?>

	<?php echo $form->textFieldRow($model,'headline',array('class'=>'span5','maxlength'=>255,'labelOptions' => array('label' => false), 'placeholder' => 'Overskrift')); ?>
	
	<?php 
	$this->widget('ext.redactor.ERedactorWidget',array(
	    'model'=>$model,
	    'attribute'=>$attribute,
	    'options'=>array(
	        'imageUpload'=>Yii::app()->createUrl('news/imageUpload',array(
	            'attr'=>$attribute
	        )),
	        'imageGetJson'=>Yii::app()->createUrl('news/imageList',array(
	            'attr'=>$attribute
	        )),
	        'imageUploadErrorCallback'=>new CJavaScriptExpression(
	            'function(obj,json) { alert(json.error); }'
	        ),
	    	'lang'=>'no_NB',	 
	    ),
	));
	?>
	
	<p><?php echo $form->textFieldRow($model,'author',array('prepend'=>'Av', 'class'=>'small','maxlength'=>255,'labelOptions' => array('label' => false), 'value'=> Yii::app()->user->name)); ?>
	
	<?php echo $form->checkBox($model,'published'); ?>
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'submit',
			'type'=>'primary',
			'label'=>'Lagre',
		)); ?>

<?php $this->endWidget(); ?>


Could it be the bootstrap fudging with it?

Appriciate all help :) thx
0

#2 User is offline   janisto 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 30-March 11
  • Location:Helsinki, Finland

Posted 31 December 2012 - 04:57 AM

Define $attribute before the widget (db field). I was using it there so that I don't have to write it many times when using upload actions.

$attribute='text';
$this->widget('ext.redactor.ERedactorWidget',array(
...


You can also use the attribute name in the widget, if you like (change CONTROLLER_ID & MYATTRIBUTE):

        <?php 
        $this->widget('ext.redactor.ERedactorWidget',array(
            'model'=>$model,
            'attribute'=>'MYATTRIBUTE',
            'options'=>array(
                'imageUpload'=>Yii::app()->createUrl('CONTROLLER_ID/imageUpload',array(
                    'attr'=>'MYATTRIBUTE'
                )),
                'imageGetJson'=>Yii::app()->createUrl('CONTROLLER_ID/imageList',array(
                    'attr'=>'MYATTRIBUTE'
                )),
                'imageUploadErrorCallback'=>new CJavaScriptExpression(
                    'function(obj,json) { alert(json.error); }'
                ),
                'lang'=>'no_NB',         
            ),
        ));
        ?>


View PostSolid, on 29 December 2012 - 07:12 PM, said:

Hi!

Anyone got the imageUpload from the Yii-Redactor-extension to work?

I have a few questions regarding it, first off: What is the 'attribute'=>$attribute supposed to be? I just dont understand what string it would need there.

Secondly, when i just define 'attribute' => 'text' (that is the attribute for the entry in the table im using redactor for) it loads allright, but when i try to upload the image, it thinks for a short while, but no image is uploaded.

The Controller:
	public function actions()
    {
        return array(
            'imageUpload'=>array(
                'class'=>'ext.redactor.actions.ImageUpload',
                'uploadCreate'=>true,
            ),
            'imageList'=>array(
                'class'=>'ext.redactor.actions.ImageList',
            ),
        );
    }


The view:
$this->widget('bootstrap.widgets.TbBox', array(
    'title' => 'Opprett nyhet',
    'headerIcon' => 'icon-home',
    'content' => $this->renderPartial('_form', array('model'=>$model), true) // $this->renderPartial('_view')
));


The _form:
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
	'id'=>'news-form',
	'enableAjaxValidation'=>false,
)); ?>

	<?php echo $form->errorSummary($model); ?>

	<?php echo $form->textFieldRow($model,'headline',array('class'=>'span5','maxlength'=>255,'labelOptions' => array('label' => false), 'placeholder' => 'Overskrift')); ?>
	
	<?php 
	$this->widget('ext.redactor.ERedactorWidget',array(
	    'model'=>$model,
	    'attribute'=>$attribute,
	    'options'=>array(
	        'imageUpload'=>Yii::app()->createUrl('news/imageUpload',array(
	            'attr'=>$attribute
	        )),
	        'imageGetJson'=>Yii::app()->createUrl('news/imageList',array(
	            'attr'=>$attribute
	        )),
	        'imageUploadErrorCallback'=>new CJavaScriptExpression(
	            'function(obj,json) { alert(json.error); }'
	        ),
	    	'lang'=>'no_NB',	 
	    ),
	));
	?>
	
	<p><?php echo $form->textFieldRow($model,'author',array('prepend'=>'Av', 'class'=>'small','maxlength'=>255,'labelOptions' => array('label' => false), 'value'=> Yii::app()->user->name)); ?>
	
	<?php echo $form->checkBox($model,'published'); ?>
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'submit',
			'type'=>'primary',
			'label'=>'Lagre',
		)); ?>

<?php $this->endWidget(); ?>


Could it be the bootstrap fudging with it?

Appriciate all help :) thx

1

#3 User is offline   Solid 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 60
  • Joined: 29-December 12
  • Location:Kristiansand, Norway

Posted 05 February 2013 - 05:11 AM

Okey, here we go again :)

Thx for your reply Janisto, and thank you for taking time to create extensions for new yii-users like my self.
Its a steep learningcurve.

So, after a break from the Redactor widget, as i got frustrated over the image uploadthingie. Im now trying again, but i do not get much closer to a working upload.

Im gonna try to explain my problem as precise as i can:

All files in ext.redactor is where they are supposed to, i've quadruplechecked it.
The editor loads fine, and the insert image window opens fine.

But when i click "Choose File" and select a image, nothing happens exept the window closes. If i press "Choose File" again, it does show the filename instead of the "no file choosen"-text. When i click insert im sendt back to the editor, but nothing shows in the text-area.

No folder is created, no errormessage is displayed.

I've allso experimented with filling the folder with images myself, following the pattern /CONTROLLER_ID_NOCAPITALLETTERS/ATTR/

My attr and controller is set in the widget-config, and should be correct.
$attribute='info';
$this->widget('ext.redactor.ERedactorWidget',array(
    'model'=>$model,
    'attribute'=>$attribute,
    'options'=>array(
        'fileUpload'=>Yii::app()->createUrl('wine/fileUpload',array(
            'attr'=>$attribute
        )),
        'fileUploadErrorCallback'=>new CJavaScriptExpression(
            'function(obj,json) { alert(json.error); }'
        ),
        'imageUpload'=>Yii::app()->createUrl('wine/imageUpload',array(
            'attr'=>$attribute
        )),
        'imageGetJson'=>Yii::app()->createUrl('wine/imageList',array(
            'attr'=>$attribute
        )),
        'imageUploadErrorCallback'=>new CJavaScriptExpression(
            'function(obj,json) { alert(json.error); }'
        ),
    ),
));
(Attribute = info, Controller= WineController)

Anyone know where i've stepped wrong? Thx
0

#4 User is offline   janisto 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 30-March 11
  • Location:Helsinki, Finland

Posted 05 February 2013 - 05:32 AM

Start by checking what that dialog returns with Firebug (Net/XHR). See if the images are created at the right place and that they have the proper permissions.

Also check if there are errors in your logs.
1

#5 User is offline   janisto 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 30-March 11
  • Location:Helsinki, Finland

Posted 05 February 2013 - 06:51 AM

View PostSolid, on 05 February 2013 - 05:11 AM, said:

I've allso experimented with filling the folder with images myself, following the pattern /CONTROLLER_ID_NOCAPITALLETTERS/ATTR/


BTW, files should be generated to uploads/MODEL/FIELD/filename.ext, so try adding files to "uploads/wine/info/"-folder.
1

#6 User is offline   Solid 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 60
  • Joined: 29-December 12
  • Location:Kristiansand, Norway

Posted 05 February 2013 - 07:05 AM

The model has the same name, wine, so thats not the problem.
Im gonna need some time to learn alittle about firebug, thx for the help so far.
Appriciated.
0

#7 User is offline   rizal13 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 05-February 13
  • Location:Indonesia

Posted 05 February 2013 - 10:42 AM

I got the same problem, the image upload didn't work.
I got the following error on firefox's web console when clicking the insert image icon:

../../imageList.html?attr=isi [HTTP/1.0 403 Forbidden 125ms]


Folder permission is Ok, any suggestions?

Note:
I'm using the latest Yii (Yii-1.1.13).
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users