Smarty permissions problems
Proper permissions solved it for me:
chown -R www-data /var/www/HRTRL
Could it be a problem with relative paths? Could you add the complete paths for you set****Dir functions, so you'll be sure you're using the correct locations.
If you call this from a /specialdir/thisdirhasonlyaPHPfile/file.php location, you might get in trouble.