module widget outside of the module


(Billfarber) #1

Is it possible to use a module widget outside of the module? If so, how do I go about doing that?

For example, I recently converted the blog tutorial to a module (thx Pradhan!), and I created a Recent Posts widget (very similar to the Recent Comments widget) that I would like to use not only within the module but also on all of the pages of my site outside of the module. Is there an easy way to do this?

Thanks!


(Gustavo) #2

$this->widget('myModule.components.MyWidget');


(Billfarber) #3

Thanks for your reply.

I’m getting the following error message:


include(Post.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory

Do I have to do anything else to access the modules models?


(Gustavo) #4

try to import the post module inside the widget

something like


Yii::import(''MyModule.models.Post);


(Billfarber) #5

That did it! Thanks!


(Benkuhl) #6

This is what I was looking for, thanks!!


(Alvarocardona91) #7

Gracias no sabia como hacerlo :)


(Anurasn) #8

Thank you very much for your great help. This help me too. :)