• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
odd relative path behaviour

#1
[eluser]neomech[/eluser]
Hi,

I'm fairly new to CI but I'm loving it and have built most of my app without too much trouble. I've run across something odd, and I'm not sure if it's a bug or if I'm just missing something obvious, so I thought I'd post here for help (let me know if there's somewhere better to post!)

I have the following bit of code in my routes.php file:

Code:
$route['(:any)-reviews'] = "category/parent/$1-reviews";
It works great. If someone goes to www.mysite.com/movie-reviews, it calls my "category" controller, the "parent" function, and passes "movie-reviews" to the function as a variable. I call a view from that controller that displays great, and of particular note (you'll see below why), all of my relative urls for my images work just fine. An image like public_html/images/image1.jpg can be called in the view using src="image/image1.jpg". If I inspect an image it returns the proper url of "http://www.mysite.com/images/image1.gif"

Now, I was messing with adding some additional information to my url (say, the number of movie reviews to return), and it works, but all of my image paths in my view go wonky.

So if I do something really basic like add this route (I'd normally use variables, but I'll just hardcode "shortlist" and "25" to show what I mean):

Code:
$route['(:any)-reviews/short_list'] = "category/parent/$1-reviews/25";

...everything works, I can add a second input to my controller that properly takes the "25", but all of my images fail, because now they all point to "http://www.mysite.com/movie-reviews/images/image1.gif".

Any idea what's happening here? I'd expect this behaviour maybe if I was using ../image/image1.gif, but if I'm using image/image1.gif, I expect it to be relative to the website's base url (if that makes sense).

I like relative paths and know I could make use of base_url() variables and such, but was just wondering why this was happening instead of just throwing my hands up in the air and doing it differently.


Messages In This Thread
odd relative path behaviour - by El Forum - 09-04-2009, 07:10 PM
odd relative path behaviour - by El Forum - 09-04-2009, 07:24 PM
odd relative path behaviour - by El Forum - 09-04-2009, 07:54 PM
odd relative path behaviour - by El Forum - 09-04-2009, 08:48 PM
odd relative path behaviour - by El Forum - 09-05-2009, 04:15 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.