INFO ¶
This widget builds an elFinder (http://elfinder.org) instance that will allow you to upload files easily. There are not file edits required. All you have to do is pass the right properties to the widget instance and it will do the rest.
Author: Vincent Gabriel (vadimg88[at]gmail.com)
Installation ¶
-1. Create a folder called 'widgets' under 'protected/'.
-2. Copy the elfinder directory to the widgets directory.
-3. In your view file paste the following:
<?php $this->widget('widgets.elFinder.FinderWidget', array(
'path' => '/path/to/uploads/dir', // path to your uploads directory, must be writeable
'url' => 'http://url/to/uploads/dir', // url to uploads directory
'action' => $this->createUrl('site/elfinder.connector') // the connector action (we assume we are pasting this code in the sitecontroller view file)
)); ?>
-4. Make sure the page has the element that will show the actual widget. By default the selector is '#elfinder', Buy you can change that by setting 'selector' => '.some_class' in the widget parameters. Example Div:
[html]
<div id="elfinder"></div>
-5. In the view file controllers you need to add the following to an actions action:
public function actions() {
return array(
'elfinder.' => 'widgets.elFinder.FinderWidget',
);
}
To make sure it will direct the action call to the widget action connector.
-6. In case that this doesn't work and you get a 404 exception that the system cannot find that action or url. If you are using custom url manager or the path option in the url manager, You need to add the '.' to the allowed chars for action names. So if i had a rule like this:
"site/<_c:([a-zA-z0-9-]+)>/<_a:([a-zA-z0-9-]+)>/*" => 'site/<_c>/<_a>/',
The above does not allow '.' in the URL for action names (we need that since the action name for the widget connector will be ControllerId/elfinder.connector) Change the above to
"site/<_c:([a-zA-z0-9-]+)>/<_a:([a-zA-z0-9-\.]+)>/*" => 'site/<_c>/<_a>/',
Notice the '\.' that was added to the action regex.
-7. Once you've done all that you should be able to run the page and see the elfinder widget working.
-8. To add an alias for 'widgets' just open up your config file which usually resides under protected/config/main.php and add this array to the config array if you don't have it yet:
'aliases' => array(
'widgets' => 'application.widgets',
),
FAQ ¶
-1. If you are seeing this error:
Alias "widgets.elfinder.FinderWidget" is invalid. Make sure it points to an existing directory or file.
It's because 'widgets' is not set as an alias to 'application.widgets'. You can either set an alias for 'widgets' or replace 'widgets.' with 'application.widgets.' through out the code files. I would recommend setting an alias, it's easier.
To add an alias for 'widgets' just open up your config file which usually resides under protected/config/main.php and add this array to the config array if you don't have it yet:
'aliases' => array(
'widgets' => 'application.widgets',
),
And that's it.
what version are you using?
What is the Yii version you're using?
Yes, you can customize the access rules by opening the widgets/elfinder/actions/connector.php and take a look at the function 'access' function and customize it.
Unable connect to backend
Trying your widget
elFinder answer: Unable connect to backend
but if i get connector http://yii/site/elfinder.connector
it answers: {"error":["errConf","errNoVolumes"]}
widget's config:
<?php $this->widget('widgets.elFinder.FinderWidget', array( 'path' => 'd:/www/testdrive/images', // path to your uploads directory, must be writeable 'url' => 'http://yii/images', // url to uploads directory 'action' => $this->createUrl('/site/elfinder.connector') // the connector action (we assume we are pasting this code in the sitecontroller view file) )); ?>
Seems wrong path definition?
What else may goes wrong, how to debug?
Don't update your comments, instead post new ones
My best guess is that the images path does not have writing permissions or has nothing in it it can read.
PECL fileinfo
Just an heads up for anyone using this on PHP 5.2. You'll need to install the PECL module fileinfo to use this. Otherwise you'll get a missing class error.
Unable to connect to backend
Im having this error and cant seem to get around it, "Unable to connect to backend".
I intend to use this for a content-administration article publisher. The widget does appear as I believe is expected, except with the error. I have the path typed out, and am certain this is correct. However, Ive combed through the source, and Im not certain as to what "path" and "url" are used for in conjunction with each other. Im assuming "path" must be local, and "url" is the hostname for the "path" ?
Some further documentation on this would be helpful. I may have to scrap using this due to time constraints, but would hate to do so because of a silly misunderstanding of the vars involved.
my widget is loaded as below:
<?php $this->widget('application.<administrative_tool>.widgets.elFinder.FinderWidget', array( 'path' => 'wwwroot/assets/uploads', // path to your uploads directory, must be writeable 'url' => http://mydevsite.mysite.com/assets, // url to uploads directory 'action' => $this->createUrl('article/elfinder.connector') // the connector action ) ); ?>
getting Unable connect to backend
Unable connect to backend
Trying your widget elFinder answer: Unable connect to backend
but if i get connector http://localhost/sit...inder.connector it answers: {"error":["errConf","errNoVolumes"]}
widget's config:
<?php $this->widget('application.widgets.elfinder.FinderWidget', array( 'path' => '/images', // path to your uploads directory, must be writeable 'url' => 'http://localhost/site/images/', // url to uploads directory 'action' => $this->createUrl('Details/elfinder.connector') // the connector action (we assume we are pasting this code in the sitecontroller view file) )); ?>I am using yiii 1.1.8
Not really working for me...
Using php 5.3, yii-1.1.10, and I get the following error:
FinderWidget cannot find the view "main".
Working with modules
I'm looking for solution to work with modules. Now i get backend error. It looks like something is wrong with routes
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.