dckurushin
(Diavolonok)
September 26, 2011, 4:03pm
1
Tried to do this:
http://yii.yiichina.org/wiki/146/how-to-use-a-widget-as-an-action-provider/#c3714
But it don’t work.
for example I have the route: /site/test.rr.html
I add in actions in SiteController
'test.'=>'application.components.widgets.UsersOnline',
And than in my UsersOnline widget
I added
public static function actions(){
return array(
'rr'=>'someName',
'route2'=>'someName2',
);
}
public function someName(){ echo 'test';}
Why it don’t works?
Maybe some route issue?
THe only route I have is :
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
dckurushin
(Diavolonok)
September 26, 2011, 4:26pm
2
All the idea behind it - I created a widget that calc how much users online, and saves data about them…
I want it to have some page where I will show all users online in table
I can create for it separate action… but it would be little bit ugly…
dckurushin
(Diavolonok)
September 26, 2011, 9:06pm
4
Little update:
When I use strict parsing, it don’t work at all, when I dont use strict parsing I get 500
2011/09/27 00:04:25 [error] [php] include(someName.php) [<a href=‘function.include’>function.include</a>]: failed to open stream:
dckurushin
(Diavolonok)
September 27, 2011, 6:46am
5
I gave up, can’t get it to work like in the wiki
eirikhm
(Eirikhm)
September 27, 2011, 7:09am
6
Please show the complete source, so it’s easier to see the problem
dckurushin
(Diavolonok)
September 27, 2011, 8:41am
7
You have the complete source actually…
Site controller with:
public function actions()
{
return array(
'test.'=>'application.components.Test',
);
}
And a widget in components
<?php
class Test extends CWidget{
public static function actions(){
return array(
'rr'=>'someName',
);
}
public function someName(){ echo 'test';}
public function run()
{
}
}
trying to access test.rr
mdomba
(Maurizio Domba Cerin)
September 27, 2011, 9:13am
8
dckurushin
(Diavolonok)
September 27, 2011, 10:16am
9
mdomba they are talking about creating CAction… but I want like this one described here
http://yii.yiichina.org/wiki/146/how-to-use-a-widget-as-an-action-provider/#c3714
Jut want to create some function inside the widget like "foo"
route to it, and access it like controllers action.
mdomba
(Maurizio Domba Cerin)
September 27, 2011, 10:21am
10
I understand what you would like… but this is not working as explained in the thread I gave you…
Above that read the last sentence on the comment you posted… it say:
It does not say that this worked for him.