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?

http://yiiframework.com/doc/api/1.1/CModule#basePath-detail

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?

Like:


Yii::app()->getModule('moduleName')->getBaseUrl()

should return:

/yiiAppName/protected/modules/moduleName

Why I’m asking this?

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

/yiiAppName/protected/modules/moduleName/js/script.js

[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);