Yii multiselect widget - yii-extensions

I have the following code that produces a jquery ech multiselect menu widget in Yii. (Eric Hynds multiselect).
I have downloaded the extension and unzipped in extensions folder
and my folder structure is My_lokal_Yii/protected/extensions/EchMultiSelect/EchMultiSelect
this is my view file code..
<?php $this->widget('ext.EchMultiselect.EchMultiselect', array(
'model' => $model,
'dropDownAttribute' => 'color',
'data' => $list,
'dropDownHtmlOptions'=> array(
'style'=>'width:378px;',
),
));?>
and in config/main.php i have imported the extension as
'import'=>array(
'application.models.*',
'application.components.*',
'application.extensions.EchMultiselect.*'
),
But i am getting error that "Alias "ext.EchMultiselect.EchMultiselect" is invalid. Make sure it points to an existing PHP file and the file is readable."
I have given all the permissions for the EchMultiselect file.
Please help me in this.. Thank you.. I tried a lot but did't get the exact result..

my folder structure is
My_lokal_Yii/protected/extensions/EchMultiSelect/EchMultiSelect
but in your config/main.php, there is:
... 'application.extensions.EchMultiselect.*'
------------------------------------^
It lacks the capital letter "s" and therefore the exact path/naming to/of your extension, I had the same "problem" with it ;-) , maybe it helps...
Greetings

Related

.htaccess how to display long sub-directory urls as short urls in address bar?

I've been trying to solve this problem for a couple of days now.
My root folder is https://www.example.com, I have many articles on it but in different folders and sub-folders for better organizing.
The problem is that I want links to look better and not like:
> https://www.example.com/reviews/review_1/index.html
/review_2/index.html
/review_3/index.html
or
https://www.example.com/articles/blog/content_1/index.html
/content_2/index.html
/content_3/index.html
but instead, I want all folders under "reviews and articles" to appear like root/dirs:
https://www.example.com/review_1/index.html
https://www.example.com/content_1/index.html
...so is it possible to exclude ../reviews/ or ../articles/blog/ folder somehow, but to have the same directory structure and also not to have duplicate content, indexes or duplicate DIRs?
EDIT / I found the solution:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteRule ^review_1/(.*) reviews/review_1/$1
This code will redirect from folder reviews/review_1/ to unexisting folder review_1 on root and copy all content from reviews/review_1/ to review_1.
just create an associative arrow specifying the mapping between url's and what they mean under the hood, for example I use in php like this-
$route = array(
array(
'url' => 'review_1/index.html',
'map_to' => '/articles/blog/reviews/index.html'
),
array(
)
);
or better version like implementing simple routing-
$route = array(
array(
'url' => '/review/',
'controller' => 'controller_class',
'action' => 'model_class'
),
array(
)
);
better proceed with second process..
do some research in implementing routing yourself or use basic framework.
Hope it helps.

Change location of controller inside of Yii

I want to change the location of my siteController from protected/controllers to protected/backOffice/controllers.
I have tried to do the following inside of the main config file but it gives me a CExxception error and its doesnt give the much of information
Unable to resolve the request "site/error". (C:\Users\steve\Sync\Frameworks\yii\framework\web\CWebApplication.php:286)
and i have the following inside of the import
'import'=>array(
'application.models.*',
'application.components.*',
'application.backoffice.*',
),
How i can do this i have found this little helper but still cant understand where i have to put it.
Link
According to your config file, it should look like:
'controllerPath'=>'protected/backoffice', <== Add this line
'import'=>array(
'application.models.*',
'application.components.*',
//'application.backoffice.*', <=== You don't need this
),
You can achieve the single controller in backoffice by:
Removing the controllerPath from main.php and add the following:
'controllerMap'=>array(
'booklet'=>array(
'class'=>'application.backoffice.Booklet', //<== Your controller name
),
),

app can't find module?

I am working on a project. It was fine until I installed new windows on my PC. But now project is same and when I access
Yii::app()->controller->module
It returns null. It also returns null for: Yii::app()->controller->module->id. When I viewed config file it had admin module in it. I don't know why is it's returning null. Can't find a way out.
Module in config file is like:
'modules' => array(
// uncomment the following to enable the Gii tool
'admin',
'gii' => array(
'generatorPaths' => array(
'bootstrap.gii'
),
'class' => 'system.gii.GiiModule',
'password' => '1234',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters' => array('127.0.0.1', '::1'),
),
),
When you access Yii::app()->controller->module then it will return the module that current controller belongs to. It returns null if the controller does not belong to any module. Please make sure the current controller you accessed which is belong to any module you configured.
You can see this link: http://www.yiiframework.com/doc/guide/1.1/en/basics.module to work with Module.
If you want to see which modules are loaded then use:
print_r(Yii::app()->getModules());
You are not 'in' a module and want to get a specific module (like admin module): you can do
Yii::app()->getModule('admin');

how to create a link to a module in yii ?

Hello and thanks for reading.
I was wondering how i can link to a file from my main site to a module
eg ;
if i am in protected/views on a file and i want to link to protected/modules/user/profile where i call an action.
Now i get an error that states that action user does not exists.
How can i create a link to a module following the following yii sintax ;
<?php echo CHtml::link('Link Text',array('link to module',
'param1'=>'value1')); ?>
<?php echo CHtml::link(Yii::app()->createurl('Module/Controller/Action'),array(
'param1'=>'value1')); ?>
this may help with combining CHtml::link with a link to a module and it's controller/action combination:
echo CHtml::link("click here",
Yii::app()->createurl('/module/controller/action', array(
'id' => $model->id // Params
))
);
i managed to figure it out i tried to put this and it works ''/user/profile''
anybody has other ideas let me know

File upload with Yii's ActiveForm

I am trying to use Yii's ActiveForm to create a basic registration page with an image upload field. However, I am running into problems. I am using the following code to create the form tags:
$form=$this->beginWidget('CActiveForm', array(
'id'=>'activity_form',
'enableAjaxValidation'=>true,
'stateful'=>true,
'enctype'=>'multipart/form-data'
));
The above code produces the following error message in Yii:
Property "CActiveForm.enctype" is not defined
I've also tried:
$form=$this->beginWidget('CActiveForm', array(
'id'=>'activity_form',
'enableAjaxValidation'=>true,
'stateful'=>true,
array('enctype'=>'multipart/form-data')));
as well as:
$form=$this->beginWidget('CActiveForm', array(
'id'=>'activity_form',
'enableAjaxValidation'=>true,
'stateful'=>true),
array('enctype'=>'multipart/form-data')));
But neither of these work.
Any ideas as to what could be wrong? Can I use beginWidget to create a multipart form with file upload capabilities? What's the format I should follow for this? I can't seem to find any answers in the documentation or the forums.
Thanks!
Never mind. I found the solution to this. The trick is to use htmlOptions like so:
$this->beginWidget('CActiveForm', array(
'id'=>'activity_form',
'enableAjaxValidation'=>true,
'stateful'=>true,
'htmlOptions'=>array('enctype' => 'multipart/form-data')
));