Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) 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

<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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-23 22:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found