|P is for Practical|
Re: Question about web trees, html paths, and HTML::Templateby Cody Pendant (Prior)
|on Apr 06, 2008 at 02:40 UTC||Need Help??|
I'm not sure what's going on in your second case, i.e. "If I move the /images under /admin (see below), no joy", but the first case the missing image is entirely to be expected.
If your template contains
and you use that template to render a page at the URL
then, no, the image isn't "there", because "there", in that case, is the admin folder, and the path you're telling the browser to look at is
and it isn't there.
You need to stop thinking about the location of the HTML::Template files. It makes no difference to the output. It doesn't matter where they are. They could be 47 folder levels down, or on another part of the filesystem altogether for all the browser cares.
Instead, think about it from the browser's point of view. All the browser knows is that it's been given some HTML, at an admin folder URL, and told there's an image one folder down. And there isn't.
What I would do is always use root-relative paths.
If your images are in domain.name.com/foo/images/, then make all references to the begin with a leading slash:
it's easy to remember, gives you a consistent policy for both software and people to work with, and solves problems moving your code from one server to another.
Nobody says perl looks like line-noise any more