action providing widget

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>',

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…

up

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:

I gave up, can’t get it to work like in the wiki :(

Please show the complete source, so it’s easier to see the problem :)

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

Check this thread for more info - http://www.yiiframework.com/forum/index.php?/topic/16357-

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.

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.