How can I generate in PINP , internal STATIC URL ?

11 views
Skip to first unread message

jlescribanoc

unread,
Feb 17, 2012, 6:43:55 AM2/17/12
to Ariadne
Hi folks !

I need to link to specific graphics in folder objet

URL that I need is STATIC, realtive to site object

When I try too make url , this is RELATIVE to object container

Auke van Slooten

unread,
Feb 17, 2012, 10:32:29 AM2/17/12
to Ariadne
Hi,

The best way to generate a img url is something like this:

<img src="<pinp> echo make_url( currentsite() ); </pinp>images/
my_image.gif">

or with the new ar() library:

<img src="<pinp> echo ar('loader')->makeURL( ar('store')-
>currentSite() ); </pinp>images/my_image.gif">

This way all your image paths are relative to the site root of the
site that the template is called on. So if you later move the site, or
export it and import it somewhere else, all the paths are
automatically correct.

There is an improvement on this, you can set the often used urls in
the config.ini once, instead of calculating them a few times, e.g.:

psite::config.ini
<pinp>
$arConfig = ar::getvar('arConfig');
$arConfig['settings'] = array(
'site' => $path,
'siteURL' => ar('loader')->makeURL().
'graphicsURL' => ar('loader')->makeURL('graphics/', false, false)
);
putvar('arConfig', $arConfig);
return $arConfig;
</pinp>

then in your other templates do this:

<pinp>
$graphicsURL = ar::acquire('settings.graphicsURL');
</pinp>
<img src="<pinp> echo $graphicsURL; </pinp>my_image.gif">

regards,
Auke

jlescribanoc

unread,
Feb 23, 2012, 4:44:30 AM2/23/12
to Ariadne
Great

Works first solutions ....

On Feb 17, 4:32 pm, Auke van Slooten <a.c.van.sloo...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages