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.
Page 1 of 1
Cannot Figure Out baseURL and folders trying to put images on my page
#2
Posted 28 April 2012 - 06:51 AM
fpolli, 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.
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
#3
Posted 28 April 2012 - 06:53 AM
drylko, 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
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.
Share this topic:
Page 1 of 1

Help












