Regarding Modules

Couple of quick questions:

  1. How can I retrieve the ID of the current module? i.e. like you can do Yii::app()->controller->id to get the controller id. There does not seem to be a Yii::app()->module->id equivalent.

  2. How can I reference a view file that exists in another module? I.e in ‘member/views/enquiry/create.php’ file I want to use ‘renderPartial’ to reference the view ‘_form’ that exists in ‘admin/views/enquiry’.

  1. you should know, which module you are "in"

  2. renderPartial(’/admin/views/enquiry’);

Yii::app()->controller->module->id. Or inside a controller: $this->module->id. There can be several modules loaded at once, so you have to "ask" a controller, which module it belongs to.

Thanks guys.

Yii::app()->controller->module->id works for me (I am doing the check in the model).

But renderPartial(’/admin/views/enquiry/_form’); does not work, it says it cannot find the view.

@gstar, I’d love to know the answer to your second question re: rendering another modules view. I’ve asked the similar question here. If you do find an answer it would be great if you could post your solution.

Thanks,

Paul

What’s about renderPartial(‘admin.views.enquiry._form’)? Check the path twice.

Lol that has actually worked! Thank you!

This works both in model, controller and view

Yii::app()->controller->module->id

thanks