resources path

1 view
Skip to first unread message

Baluta Cristian

unread,
Oct 16, 2009, 8:04:30 AM10/16/09
to haxig...@googlegroups.com
Hi, i've guessed from the build.sh file that i need a resources folder with photos and other stuffs from the website. i've created resources/gfx/logo.png and i'm loading it with <img src="gfx/logo.png">
the gfx folder is copied correctly in www and the logo is also displayed in page, the problem comes when i call my page with www/index.php
it tries to load index.php/gfx/logo.png, which obviously is not working (not sure why safari doesn't tell me about the wrong path)

Any advice on how to call my resources? Or is it a bug?

--
Băluță Cristian
http://ralcr.com
http://imagin.ro

Andreas Söderlund

unread,
Oct 16, 2009, 8:23:54 AM10/16/09
to haxig...@googlegroups.com
On Fri, Oct 16, 2009 at 2:04 PM, Baluta Cristian <cristi...@gmail.com> wrote:
Hi, i've guessed from the build.sh file that i need a resources folder with photos and other stuffs from the website. i've created resources/gfx/logo.png and i'm loading it with <img src="gfx/logo.png">
the gfx folder is copied correctly in www and the logo is also displayed in page, the problem comes when i call my page with www/index.php
it tries to load index.php/gfx/logo.png, which obviously is not working (not sure why safari doesn't tell me about the wrong path)

That's true, I get the same thing but with a quirk: If I request the index page without an appending slash, it works:

http://localhost/index.php - "gfx/logo.png" is displayed.
http://localhost/index.php/ - "gfx/logo.png" it's not.

So I guess the browser thinks that index.php is a path when resolving the relative path, if a slash is appended... Anyway, the problem is alleviated by using Url.linkUrl(). If you assign it to the view like this:

this.view.assign('linkUrl', haxigniter.libraries.Url.linkUrl());

Then you can prepend that value to all your links and they will work no matter in what subdirectory you put them:

<img src="::linkUrl::/gfx/logo.png">

If you use a wysiwyg editor for the views, it might not like that however. Then you have to resolve to using absolute paths in the images (and js, css, and other resources):

<img src="/gfx/logo.png">

The problem with this approach is that if you're moving the project into a subdirectory, you have to rename all links of course. With the ::linkUrl:: method it's done automatically.


/Andreas

Andreas Söderlund

unread,
Oct 16, 2009, 9:38:29 AM10/16/09
to haxig...@googlegroups.com
On Fri, Oct 16, 2009 at 2:23 PM, Andreas Söderlund <cisc...@gmail.com> wrote:
So I guess the browser thinks that index.php is a path when resolving the relative path, if a slash is appended... Anyway, the problem is alleviated by using Url.linkUrl(). If you assign it to the view like this:

I've fixed a bug in Url.linkUrl(), so if doesn't work (especially with mod_rewrite) upgrade to the latest version on github or use the attached file for a drop-in replacement to src/application/libraries/Url.hx

The bugfix will be included in v0.57.


/Andreas

Url.hx
Reply all
Reply to author
Forward
0 new messages