How to get the module's path

example: my module is user, hao to ge the under the user’ floder path

CModel has a basePath property, have you tryed it?

thank you for you reply, but i want to the path effection that like baseUrl and not like basePath.

Same question here!

How to get the relative base url of a module?



should return:


Why I’m asking this?

I want to register a JavaScript file, that is located in a module:


[s]I would it register this way (function init() of moduleName):

Yii::app()->clientScript->registerScriptFile($this->getBaseUrl.’/js/script.js’, CClientScript::POS_HEAD);

Or is there a better way?[/s]

Okay, the better way - works :)

function init() of a module:

// publish and insert script.js into the <head> section

$urlScript = Yii::app()->assetManager->publish(Yii::getPathOfAlias('moduleName').'\js\script.js');

Yii::app()->clientScript->registerScriptFile($urlScript, CClientScript::POS_HEAD);