Snippets

Create an account or login to be able to add, comment and rate snippets.

Navigation

Compute public path

Here is how you can get public path to i.e. http://www.domain.com/flash/charts/chart.swf

Put this code into your template.

<?php
echo image_path('/flash/charts/chart.swf', true);
?>

Tnx Matt. This is the function I was looking for :)

by Damjan Malis on 2006-08-07, tagged url 

Comments on this snippet

gravatar icon
#1 Matt Robinson on 2006-08-08 at 11:51

Could you clarify a couple of things for me?

  1. I thought convention made functions/methods beginning with an underscore "private" or at least internal, and so liable to change? Isn't this more likely to break in future because it's not "official API"?

  2. How is this different to: echo image_path('/flash/charts/chart.swf');

  3. What's the "true" for? Why is the extension separate from (what I assume is) the filename?

gravatar icon
#2 Romain Dorgueil on 2006-08-08 at 07:32

Hum

RTFS? (read the fucking source...)

Ok you can try opening the AssetHelper to read it

The true is to say "use absolute path" instead of image relative path.

and for question 1... what function/method begins with an _ ?

gravatar icon
#3 Damjan Malis on 2006-08-08 at 08:29

Romain,

I have changed the snippet ... first version of this snippet was:

_compute_public_path('charts', 'flash/charts', 'swf', true) or something ...

anyway now I know that I can use image_path for locating public paths to my directories under /web

cya

You need to create an account or log in to post a comment or rate this snippet.