|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Unknown Relic Smarty Rookie
Joined: 28 Apr 2004 Posts: 9
|
Posted: Mon Sep 06, 2004 9:32 am Post subject: Use include_path for compile directory |
|
|
In the interests of keeping all of the *_dir variables consistent it would be nice if they all took advantage of the include_path php.ini option. Right now (for example) Smarty::template_dir and Smarty::config_dir will use the include_path, while Smarty::compile_dir and Smarty::cache_dir don't -- as noted in the documentation.
The following function's a bit rough, but works with php >= 4.3.0 and may help those who want to use a directory inside their include_path to store compiled templates. A method to set the cache directory could easily be derived from this as well.
[php:1:0fbdeb9ce5]
function set_compile_dir($compile_dir, $use_include_path = true)
{
$this->compile_dir = $compile_dir;
// Ensure the directory doesn't exist outside of include_path.
if ( $use_include_path && !file_exists($compile_dir) ) {
if ( PHP_OS != 'WINNT' && PHP_OS != "WIN32" ) {
$IncludePaths = explode(':', get_include_path());
}
else {
$IncludePaths = explode(';', get_include_path());
}
foreach ( $IncludePaths as $Path ) {
if ( file_exists($Path . $compile_dir) ) {
$this->compile_dir = $Path . $compile_dir;
break;
}
}
}
}
[/php:1:0fbdeb9ce5]
Hopefully someone finds this useful. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|