Yii Framework Forum: Cannot Figure Out baseURL and folders - Yii Framework Forum

Jump to content

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

Cannot Figure Out baseURL and folders trying to put images on my page Rate Topic: -----

#1 User is offline   fpolli 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 60
  • Joined: 26-April 12

Posted 28 April 2012 - 06:17 AM

I apologize in advance for being completely dense, but I do not understand OOP in action (I understand the principles, but when faced with OOP code, a fog envelops my brain), and I do not understand yii.

I am trying to put an image on my index page. I gather that you use CHtml::image($src, $alt, $htmlOptions). As the value for $src, you are supposed to use:

Yii::app()->request->baseUrl . '/path/to/image.jpg'

I cannot for the life of me figure out what actual folder on my server baseURL points to. When I echo dirfile(__FILE__), the result I get is:

blah/blah/webroot/protected/views/site

So I made a folder in site called images.

I put <?php echo CHtml::image(Yii::app()->request->baseUrl . '/images/mypic.jpg') ?> in the index.php file, and I get the broken image icon.

I have a decent handle on procedural PHP, but my brain is so far unable to make the jump to OOP. I had the same issue with C++ decades ago.
0

#2 User is offline   drylko 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 86
  • Joined: 13-September 09
  • Location:Poland

Posted 28 April 2012 - 06:51 AM

View Postfpolli, on 28 April 2012 - 06:17 AM, said:

So I made a folder in site called images.

I put <?php echo CHtml::image(Yii::app()->request->baseUrl . '/images/mypic.jpg') ?> in the index.php file, and I get the broken image icon.



Hi, this dir holdes your views only, not assets.
Your baseUrl usually points to your webroot directory. So there is a place for a folder like images. Do not put assets in your protected folder unless you are using them with asset manager to publish them in your webroot.assets.

pd
0

#3 User is offline   fpolli 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 60
  • Joined: 26-April 12

Posted 28 April 2012 - 06:53 AM

View Postdrylko, on 28 April 2012 - 06:51 AM, said:

Hi, this dir holdes your views only, not assets.
Your baseUrl usually points to your webroot directory. So there is a place for a folder like images. Do not put assets in your protected folder unless you are using them with asset manager to publish them in your webroot.assets.

pd


Thank YOU.

Now I think I understand how the process works, so I should be able to replicate it.
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