File::relPath()
\nn\t3::File()->relPath($path = '');
relative path (from the current script) to a file / directory. If no path is specified, the Typo3 root directory is returned.
\nn\t3::File()->relPath( $file ); => ../fileadmin/image.jpg
\nn\t3::File()->relPath(); => ../
Copied!
| @return string
Source Code
public function relPath($path = '')
{
if (!$path) $path = \nn\t3::Environment()->getPathSite();
$isFolder = $this->isFolder($path);
$path = $this->absPath($path);
$name = rtrim(PathUtility::getRelativePathTo($path), '/');
if ($isFolder) $name .= '/';
return $name;
}
Copied!