Link to home
Start Free TrialLog in
Avatar of roscoeh23
roscoeh23

asked on

problem with smarty

Warning: Smarty error: unable to read resource: "../smarty/index.tpl" in c:\Inetpub\wwwroot\nhs\smarty\Smarty.class.php on line 1095

This is the error  get when I try to use smart on a tpl file I have created. Both the index.tpl and the smarty class are in the same folder(../smarty/). I am running it locally but want to simulate how it will work when I upload it to my webserver so have not changed the php.ini or anything.

This is the file...
<?
include('../smarty/Smarty.class.php');
// create object
$smarty = new Smarty;

// assign some content. This would typically come from
// a database or other source, but we'll use static
// values for the purpose of this example.
$smarty->assign('name', 'george smith');
$smarty->assign('address', '45th & Harris');

// display it
$smarty->display('../smarty/index.tpl');

?>
Avatar of funamentalist
funamentalist
Flag of Pakistan image

i think as u are working in windows platform , u should change ur paths accordingly, so instead of using /smarty/index.tpl use something like \\smarty\\index.tpl

on a side note , for development stuff with php , u should use apache as ur webserver instead of IIS on which u will most of the time have the path problems.
in smarty_conn.php , these are the settings to look into

$smarty->template_dir = MY_DIR.'templates';
$smarty->compile_dir = MY_DIR.'templates_c';
$smarty->config_dir = MY_DIR.'configs';
Avatar of roscoeh23
roscoeh23

ASKER

This file does not exist in the version I have. Although the 3 variables are in in the main smarty file but do not work. I think it is an iis permissions thing. any ideas?

hmm i dont think its a permission thing as ur working on windows. what are the values of the

$smarty->template_dir = MY_DIR.'templates';
$smarty->compile_dir = MY_DIR.'templates_c';
$smarty->config_dir = MY_DIR.'configs';

in ur main smarty file ?
if
$smarty->template_dir = MY_DIR.'templates'; is same then the path to ur tpl should be
$smarty->display('index.tpl');

with $smarty->display('../smarty/index.tpl'); ur script is looking for index.tpl on the root folder

can u tell me :
1 : path to ur templates from the root
2 : $smarty->template_dir = MY_DIR.?
3 : the location of ur php script

I my smarty.class.php I have variables

  var $template_    =  'templates';
 var $compile_     =  'templates_c';
 var $config_      =  'configs';


which are part of the smarty class. My structure is this

smarty is the top folder

then I have files

smarty compiler class
config file class
smarty class

also in the same directory (smarty) I have the 3 folders

'templates' - caontains index.tpl
'templates_c';
 'configs';
'internals'
'pluggins'


I have also moved the basic index.php file into this smarty folder  and now it points to

$smarty->display('templates/index.tpl');

This should all be ok but now I get this error

Call to undefined function name()  
move the file index.php on the root and change

$smarty->display('templates/index.tpl');
to
$smarty->display('index.tpl');

should work
Warning: main(C:/Inetpub/wwwroot/Smarty/libs/Smarty.class.php) [function.main]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\ssn\6.php on line 5

Fatal error: main() [function.require]: Failed opening required 'C:/Inetpub/wwwroot/Smarty/libs/Smarty.class.php' (include_path='.;C:\php5\pear') in c:\Inetpub\wwwroot\ssn\6.php on line 5

Have given it another go. This is the error now seems like windows has it locked or something.
hmm i think ur getting that error as ur trying to access a file outside ur sites root directory. which is 'ssn' i think? i think if u want to use smarty with that site in IIS , you should put hte smarty directory in ssn , rather than having it in seperate directory/site.

i am not too sure about the IIS config but i think it works but creating sites with virtual directories , so from what i can see 'ssn' and 'smarty' are 2 different sites and thats why its giving you the permission error , as u cannt access files in other sites.... thats my understanding of the situation , may be someone else can shed some more light on that issue.
now getting the following so think have solved the other problem at least.

Warning: Smarty::_parse_resource_name(C:/Inetpub/wwwroot/ssn/Smarty/internals\core.get_include_path.php) [function.-parse-resource-name]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\ssn\Smarty\libs\Smarty.class.php on line 1650

Fatal error: Smarty::_parse_resource_name() [function.require]: Failed opening required 'C:/Inetpub/wwwroot/ssn/Smarty/internals\core.get_include_path.php' (include_path='.;C:\php5\pear') in C:\Inetpub\wwwroot\ssn\Smarty\libs\Smarty.class.php on line 1650
ASKER CERTIFIED SOLUTION
Avatar of funamentalist
funamentalist
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial