Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-22-2007, 04:34 AM
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-22-2007, 04:42 AM
Cristian's Avatar
Administrator
 
Join Date: Feb 2007
Location: Sibiu, Romania
Posts: 99
Default

Hello,

I personally using rewrited rules for routes. URL's will look like this:

http://www.domain.com/url-_in-a-diff...ile-under-root
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-22-2007, 04:51 AM
Junior Member
 
Join Date: Feb 2007
Posts: 26
Default

Quote:
Originally Posted by Cristian View Post
Hello,

I personally using rewrited rules for routes. URL's will look like this:

http://www.domain.com/url-_in-a-diff...ile-under-root
I'm not quite understand what you mean. All I put in .htaccess is:

Code:
RewriteEngine on
RewriteRule .* index.php

php_flag magic_quotes_gpc off
php_flag register_globals off
So, you're suggesting I add some command in my .htaccess ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-22-2007, 05:08 AM
Cristian's Avatar
Administrator
 
Join Date: Feb 2007
Location: Sibiu, Romania
Posts: 99
Default

No, I guess your format is ok for what you need.

MY routes are defined in a .ini file and i am using a format customized, derived from this format:

routes.sa.route = ":controller_:action_aram1" ...........
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-22-2007, 05:42 AM
SpotSec's Avatar
Senior Member
 
Join Date: Feb 2007
Location: United States
Posts: 116
Default

this is a slightly nicer rewrite rule
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1


I'm not exactly sure what your problem is, but I am
under the impression that you have trouble with the image path?

Wouldn't something like <?php echo $this->baseURL;?>/pub/foo/bar.jpg work for you?
Perhaps being lazy and just set everything relative to root /pub/foo/bar.jpg
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 05-22-2007, 05:56 AM
Junior Member
 
Join Date: Feb 2007
Posts: 26
Default

Quote:
Originally Posted by SpotSec View Post
Wouldn't something like <?php echo $this->baseURL;?>/pub/foo/bar.jpg work for you?
Perhaps being lazy and just set everything relative to root /pub/foo/bar.jpg
I used that solution right now. I was thinking another solution because I use Dreamweaver to edit the layout. and since the path is using PHP syntax, It's hard to keep everything displayed in dreamweaver with the current application folder structure.

btw, thx for the .htaccess suggestion
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:53 AM.