Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Question about web trees, html paths, and HTML::Template

by Cody Pendant (Prior)
on Apr 06, 2008 at 02:40 UTC ( #678589=note: print w/replies, xml ) Need Help??

in reply to Question about web trees, html paths, and HTML::Template

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

<img src="images/save_btn.gif" />
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, then make all references to the begin with a leading slash:

<img src="/foo/images/save_btn.gif" />
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
kids today don't know what line-noise IS ...

Replies are listed 'Best First'.
Re^2: Question about web trees, html paths, and HTML::Template
by bradcathey (Prior) on Apr 06, 2008 at 12:11 UTC

    So, the way I think about where an instance script in CGI::App is called from applies here as well. Makes sense now. Thanks.

    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://678589]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2020-07-14 22:25 GMT
Find Nodes?
    Voting Booth?

    No recent polls found