Difference between #5 and #10 of
How to use a Widget as an Action Provider

Changes

Title unchanged

How to use a Widget as an Action Provider

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

Widgets, CAction

Content changed

[...]
All done, now we can call all the **actionProvider** actions as **controllerID/actionPrefix.actionID**. Here is the example:


```php
index.php?
r=site/test.GetData
```
[...]
// we point to the location where the provider
// is.
'test.'=>
array(
 
         'class'=>
'application.components.testProvider',        'getData'=>array(     // property1 must be a public variable     // on getData CAction class     'property1'=>'value1',    ),
 
), ); } ``` ##Access Rules
 
Also, if you have implemented the accessRules method inside the controller, then you'll need to make sure that you _allow_ the action provider in the accessRules method, otherwise you will receive 404 error when trying to view the page. Something like this will do the trick:
 
 
 
```php 
public function accessRules()
 
    {
 
        return array(
 
            array('allow',
 
                'actions' => array('test.getData'),
 
                'users' => array('*'),
 
            ),
 
            array('deny', 
 
                'users' => array('*'),
 
            ),
 
        );
 
    }
 
 
```
 
 
 
 
 
24 0
41 followers
Viewed: 61 018 times
Version: 1.1
Category: How-tos
Written by: Antonio Ramirez
Last updated by: stinkytofu
Created on: Feb 18, 2011
Last updated: 9 years ago
Update Article

Revisions

View all history