Generating Absolute Paths in Scripts

Using the values of the fsPathPrefix and urlPrefix variables in scripts, you can generate absolute paths and URLs that work in the preview as well as on the live server.

For this purpose, an NPSOBJ instruction that generates an assignment statement in the desired script language needs to be inserted at the beginning of the base layout. Example:

<npsobj insertvalue="var" name="urlPrefix" formatter="phpVardef" />

A path can then be output to the file which is generated during the export:

<npsobj insertvalue="var" name="visiblePath" formatter="phpVardef" />
<? $absUrlPath = $urlPrefix.$visiblePath; ?>

This way of calculating the value of $absUrlPath works on the live server as well as in the preview.