We help IT Professionals succeed at work.

problem with smarty

roscoeh23
roscoeh23 asked
on
824 Views
Last Modified: 2008-03-04
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');

?>
Comment
Watch Question

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';

Author

Commented:
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

Author

Commented:
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

Author

Commented:
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.

Author

Commented:
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
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.