Possible bug in the widgets

Hi, my name is Juan Manuel from Colombia…I do not know much English but I hope you understand me…

Today I was writing a widget that got a record from the DB and everything was fine when run up and left me an error saying ‘PostMoreVisited does not have a method named “getModule”’, I do not understand why I asked that the widget has a method called “getModule” but then I did was I created this method in the widget as follows:

public function getModule(){}

And it worked!

Why? … this is a mistake of mine or the framework?

Thanks! ;)

Note: This was with version 1.0.7

Do you extend your widget from CWidget?


My Widget is like next:

class PostMoreVisited extends CWidget


	public function run()


		$criteria=new CDbCriteria;

		$criteria->order = 'pubDate DESC, visits DESC';

		$criteria->limit = 1;







	public function getModule(){}


I know this sounds a bit stupid… but don’t you call $this->getModule() in your view file by any chance?

No, I have in the view only this:


<?php foreach($models as $model): ?>

	<?php $url = CController::createUrl('post/show',array('id'=>$model->id));?>

	<li><?php echo CHtml::link($model->title,$url,array('class'=>'permalink'));?></li>

<?php endforeach; ?>


And then, only include the next code to display the widget:

<?php $this->widget('application.components.PostMoreVisited')?>

The problem probably comes from the fact you tried to use createUrl as a static method.

In fact, you can only use that via $this->createUrl(). $this refers to the currently active controller.

As you invoked undefined method, __call() probably tried to reach the active module to figure out what you really asked for.

But, if I use "$this->" instead of "CController::" I get an error because the class inherits from CWidget and not CController.

You can use $this->controller->

Worked!!.. Thanks to "pestaa" and "tri", thank you very much you for your cooperation.