Can't Get The Correct Url Path

Hi,

If my Yii app is located in this directory http://localhost/public_html/mywebapp/

how do I tell my code below that I wanted it to automatically be set under the dir above?




<?php

/**

 *  Extending CLinkPager so that we can give it a custom css file

 */


class LinkPager extends CLinkPager

{

        public $cssFile = '/css/pager.css';

}



Dear Friend

If the following is the path of pager.css




http://localhost/public_html/mywebapp/css/pager.css



Then the following would work




public $cssFile = 'css/pager.css';




Regards.

Hi corbeeresearch

You could use also


public $cssFile = Yii::app()->baseUrl . '/css/pager.css';

I get this error

Parse error: syntax error, unexpected ‘(’, expecting ‘,’ or ‘;’ in /var/www/public_html/tots/protected/components/LinkPager.php on line 8

Unfortunately, I tried it, and didn’t work.

Sorry about that

Anywhere in my application, I can do the following to get contents of main.css in css folder.




$file="css/main.css";

echo file_get_contents($file);



Regards.

Try this


public $cssFile;


 public function init()

    {

          $this->cssFile = Yii::app()->baseUrl . '/css/pager.css';

	  return parent::init();

    }

Thanks, that does the trick!