Thread: Image pathing
View Single Post
  #1 (permalink)  
Old 05-22-2007, 04:34 AM
Tommy1402 Tommy1402 is offline
Junior Member
 
Join Date: Feb 2007
Posts: 26
Default Image pathing

Hello,
I use my company logo for the web, place it in the pub/images/logo.jpg

My directory structure:
- app (controllers (indexController.php (indexAction, testAction)), models, views)
- lib
- pub (images, scripts, styles)
- file .htaccess
- file index.php

in the file app/views/index.tpl.php (which is rendered by indexAction, I put the image src like this: pub/images/logo.jpg.

When I opened mytestweb.com , the image is displayed perfectly. I saw in the source that the image scr path is the same as above (pub/images/logo.jpg)

Now, I click the Test link in the main page that goes to http://mytestweb.com/index/test. that testAction also renders the same tpl file (index.tpl.php). The page loads perfectly only without the image displayed. I viewed source and see the image scr path is: pub/images/logo.jpg

So far my solution for this, is I created a static path in my config.ini file, load it, then use that path for the image scr path. so my image scr path in index.tpl.php looks like this:
Code:
<img src="<?php echo $this->siteName;?>/pub/images/logo.jpg">
where siteName = /mytestweb.com

So my question is, are there any different and better solution?
Thanks

Last edited by Tommy1402 : 05-22-2007 at 04:39 AM.
Reply With Quote