Yii::app()->baseUrl and relative paths

Hi,

using Yii::app()->baseUrl and Yii::app()->theme->baseUrl always generates an absolute path relative to the base URi, like:


/js/setup.js

/themes/css/

and so on.

Is there a way to generate relative paths, without starting "/" like

js/setup.js ?

Example:

I use baseUrl in this way:

Yii::app()->baseUrl.’/js/setup.js’, which generates (depending on the project) something like:

/js/setup.js

or

/development/js/setup.js (where "development" is the basic folder from the development environment.)

But what I need is this:

js/setup.js

or

development/js/setup.js

so an


Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/setup.js', CClientScript::POS_END);

should generate something like:


<script type="text/javascript" src="js/suchfeld.js"></script>

OR (for development)

<script type="text/javascript" src="development/js/suchfeld.js"></script>



Is there an option to avoid the "/" at the beginning or something like that?

Thank you,

rall0r.

I think you dont need to remove "/" but to change basePath in config/main.php.

As sensorario suggests, I also think you don’t need to remove ‘/’, in fact it’s preferred with ‘/’. But if you like to change request->baseUrl, you can do that in config/main.php in components part:




        'request' => array(

            'baseUrl' => '/base-url',

        ),



@ManInTheBox

Thank you, that is, hat I was looking for.

I’ve tried it, but it was not so easy as it looks like first. I hope, I get it work.

Right, I don’t need to remove the “/” at an default environment. But at this special situation, I need an special URL Design, which should not use absolute paths.

where i have change? Getting Error…