Probs with Windows paths
| From: | gus | Date: | Tue, 29 Jan 2002 14:39:51 +0000 |
| Subject: | Probs with Windows paths | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-2602@lists.php.net to get a copy of this message | ||
Hi!
I experienced problems with Smarty and Windows paths with drive letters (Smarty
1.5.2, PHP 4.0.6, Win2K, IIS5).
When loading a template using the display method I receive the following error:
Warning: Smarty error: unable to read template resource:
"F:/www/servers/test/templates/default/layout.html" in
F:\www\servers\test\portal\smarty\Smarty.class.php on line 1525
The reason for this behaviour is that _parse_file_path splits the filename by
the first colon and so detects a wrong resource_type.
I'll suggest the following patch:
function _parse_file_path($file_base_path, $file_path, &$resource_type,
&$resource_name) {
+ // Handle Windows filenames with drive letter
+ if (strpos($file_path, ':')==1) {
+ // no resource type, treat as type "file"
+ $resource_type = 'file';
+ $resource_name = $file_path;
+ } else
+ {
// split tpl_path by the first colon
$file_path_parts = explode(':', $file_path, 2);
if (count($file_path_parts) == 1) {
// no resource type, treat as type "file"
$resource_type = 'file';
$resource_name = $file_path_parts[0];
} else {
$resource_type = $file_path_parts[0];
$resource_name = $file_path_parts[1];
}
+ }
...
Best regards
gus