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
http://www.domain1.com/admin/
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
admin/images/
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:

<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 ...

In reply to Re: Question about web trees, html paths, and HTML::Template by Cody Pendant
in thread Question about web trees, html paths, and HTML::Template by bradcathey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.