currentsite
- Ariadne >
- Library >
- Ariadne 2.6 >
- Manuals >
- Programmers Reference >
- Classes >
- Object >
- PINP Methods >
(string) currentsite()
Returns the path to the nearest parent site.
Each site object, in the path to the current object, registers itself in
Ariadne during the configuration retrieval phase. This phase is always executed
before an object template runs, via the PHP method
CheckConfig(). currentsite() returns the path to the
nearest site object, this may also be the current object, if it is a
psite.
This method is useful to create location independant websites. You can move
the site around, and as long as you calculate all paths relative to
currentsite(), all links in your templates will remain valid.
A useful way to make this easier is to calculate a few often used paths and urls first, then call the other templates which use these values, e.g.:
<pinp>
$site=currentsite();
$site_url=make_url($site);
putvar('site',$site);
putvar('site_url',$site_url);
$graphics=$site."graphics/";
$graphics_url=make_url($site, false, false);
putvar('graphics',$graphics);
putvar('graphics_url',$graphics_url);
</pinp>
You could save the above template with the name 'init.pinp', and
call it in each top level template later, to make sure the variables are set and
available. Also, calculating it once, as above, speeds up performance, since you
don't have to call make_url() each time you want to link to a
graphical element or stylesheet.
The graphics_url above is forced to not contain session
information or language information, which will speed up the graphics, since
they can be cached. This means the graphics directory at least should be
readable by public.

