Yii Framework Forum: How to get url addres for my asset file? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to get url addres for my asset file? Rate Topic: -----

#1 User is offline   munemune 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 07-November 09

Posted 21 December 2009 - 11:48 AM

Hi, does anyone know how to get url addres for my asset file?

For example, in some php file i need to include "logo image" that reside on folder "[wwwroot/myapp] /images/logo.png", normally for php script image address i will write

MyImage('/images/logo.png');


The code above not work if i put it in "view" file, the error was "file not found". So how to write the right asset address in "view" file??

Btw, when i use
$this->redirect(wwwroot/myapp/showlogo.php)
in controller to acces my asset outside the protected folder, the page show normally (the page is not render by Yii). I assume my source problem its because url that generate by Yii.

Thanks.
0

#2 User is offline   sebas 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 495
  • Joined: 28-October 08
  • Location:Buenos Aires, Argentina

Posted 21 December 2009 - 03:58 PM

Yii::app()->request->baseUrl is the directory of your index.php main file
0

#3 User is offline   munemune 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 07-November 09

Posted 21 December 2009 - 05:51 PM

Hey, thanks it's works :)

Btw, just in case if anyone have same problem

in my "view" code above
MyImage('/images/logo.png');


I write it like this
MyImage(Yii::app()->request->baseUrl.'images/logo.png');

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users