[TYPO3] Getting PATH_tslib from within a module?

Kevin Renskers info at dualdot.nl
Tue May 9 16:28:15 CEST 2006


Kasper ligaard Nielsen wrote:
> I have installed the EXT:mwimagepath, but when accessing the BE-module I 
> get an error, since 'tslib' is hardcoded.
> I run Typo3 4, where the tslib path has been moved.
> 
> My question is if it is possible to access PATH_tslib (or something 
> equivalent) from a backend module? I.e. to make the extension work on 
> both Typo3 4 and earlier.
> 
> regards, Kasper

Something like this?

/*************************************************************
  * Define Paths for including files
  *************************************************************/
define('TYPO3_OS', 
stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
define('TYPO3_MODE', 'FE');
define('PATH_piScript', 
str_replace('/typo3conf/ext/hoicommunity/pi1/ajax.php','',str_replace('//','/', 
str_replace('\\','/', php_sapi_name()=='cgi'||php_sapi_name()=='isapi' ? 
$HTTP_SERVER_VARS['PATH_TRANSLATED']:$HTTP_SERVER_VARS['SCRIPT_FILENAME']))));
define('PATH_site', PATH_piScript.'/');
define('PATH_t3lib', PATH_site."t3lib/");

if (@is_dir(PATH_site.'typo3/sysext/cms/tslib/')) {
	define('PATH_tslib', PATH_site.'typo3/sysext/cms/tslib/');
} elseif (@is_dir(PATH_site.'tslib/')) {
	define('PATH_tslib', PATH_site.'tslib/');
} else {
	$configured_tslib_path = '';

	// example:
	// $configured_tslib_path = '/var/www/mysite/typo3/sysext/cms/tslib/';

	define('PATH_tslib', $configured_tslib_path);
}

if (PATH_tslib=='') {
	die('Cannot find tslib/. Please set path by defining 
$configured_tslib_path in '.basename(PATH_thisScript).'.');
}

define("PATH_typo3conf", PATH_site."typo3conf/");
define("TYPO3_mainDir", "typo3/");
if (!@is_dir(PATH_typo3conf))	die("Cannot find configuration. pi file is 
probably executed from the wrong location.");



More information about the TYPO3-english mailing list