Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Please Help with Installation

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
Note
Smarty n00b


Joined: 04 Apr 2012
Posts: 3

PostPosted: Wed Apr 04, 2012 10:57 am    Post subject: Please Help with Installation Reply with quote

Hello. Im currently running the latest Wampserver on Windows 7 64bit, and I have downloaded and created the paths needed for Smarty to work, but for some reason I still cannot get it working on my localhost. I have tried to methods using a load of tutorials from google, but each method either fixed 1 problem and caused another, or both halted it all together. Currently I have the following code in my index.php files inside my www folder:

Code:

// load Smarty library
$base_path= dirname(__FILE__);
require_once('C:/wamp/www/smarty/libs/Smarty.class.php');

$smarty = new Smarty;
$smarty->setTemplateDir($base_path.'C:/wamp/www/smarty/templates');
$smarty->setCompileDir($base_path.'C:/smarty/templates_c');
$smarty->setCacheDir($base_path.'C:/smarty/cache');
$smarty->setConfigDir($base_path.'C:/wamp/www/smarty/configs');

$smarty->assign('name','fish_boy!');

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


Now when I go to localhost, I get the following errors:

Quote:

Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'index.tpl'' in C:\wamp\www\smarty\libs\sysplugins\smarty_internal_templatebase.php on line 127
( ! ) SmartyException: Unable to load template file 'index.tpl' in C:\wamp\www\smarty\libs\sysplugins\smarty_internal_templatebase.php on line 127
Call Stack
# Time Memory Function Location
1 0.0015 770824 {main}( ) ..\index.php:0
2 0.0217 2349576 Smarty_Internal_TemplateBase->display( ) ..\index.php:23
3 0.0218 2349768 Smarty_Internal_TemplateBase->fetch( ) ..\smarty_internal_templatebase.php:374


Im not sure exactly what is wrong. But will anyone help me solve this please Crying or Very sad
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Apr 04, 2012 1:45 pm    Post subject: Reply with quote

Does this file exist, and readable by PHP?

Quote:
C:/wamp/www/smarty/templates/index.tpl


You can find out with this:

Code:
<?php readfile('C:/wamp/www/smarty/templates/index.tpl'); ?>


See if that spits out the template content.
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Apr 04, 2012 8:52 pm    Post subject: Reply with quote

Your path for the folders is wrong as C:/wamp/www/smarty/... is already an absolute path.

Code:
$smarty->setTemplateDir($base_path.'C:/wamp/www/smarty/templates');
$smarty->setCompileDir('C:/smarty/templates_c');
$smarty->setCacheDir('C:/smarty/cache');
$smarty->setConfigDir('C:/wamp/www/smarty/configs');
Back to top
View user's profile Send private message
Note
Smarty n00b


Joined: 04 Apr 2012
Posts: 3

PostPosted: Thu Apr 05, 2012 3:21 am    Post subject: Reply with quote

mohrt wrote:
Does this file exist, and readable by PHP?

Quote:
C:/wamp/www/smarty/templates/index.tpl


You can find out with this:

Code:
<?php readfile('C:/wamp/www/smarty/templates/index.tpl'); ?>


See if that spits out the template content.
Yes it does exist, along with dozens of other .tpl files in that folder. I have also added your statement, and I still get the same issue.

U.Tews wrote:
Your path for the folders is wrong as C:/wamp/www/smarty/... is already an absolute path.

Code:
$smarty->setTemplateDir($base_path.'C:/wamp/www/smarty/templates');
$smarty->setCompileDir('C:/smarty/templates_c');
$smarty->setCacheDir('C:/smarty/cache');
$smarty->setConfigDir('C:/wamp/www/smarty/configs');
Ok I have fixed it, but I still get the following error everytime I click localhost.

Quote:
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'index.tpl'' in C:\wamp\www\smarty\libs\sysplugins\smarty_internal_templatebase.php on line 127
( ! ) SmartyException: Unable to load template file 'index.tpl' in C:\wamp\www\smarty\libs\sysplugins\smarty_internal_templatebase.php on line 127
Call Stack
# Time Memory Function Location
1 0.0049 771176 {main}( ) ..\index.php:0
2 0.0178 2350264 Smarty_Internal_TemplateBase->display( ) ..\index.php:23
3 0.0178 2350456 Smarty_Internal_TemplateBase->fetch( ) ..\smarty_internal_templatebase.php:374


When I used a tutorial it said to add the Smarty path inside my includes_path, but that didn't fix anything. SO I reverted my php.ini back and this is what I currently have:

Quote:
; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
;
; PHP's default setting for include_path is ".;/path/to/php/pear"
; http://php.net/include-path


Now this is my altered code:

Code:
// load Smarty library
$base_path= dirname(__FILE__);
require_once('C:/wamp/www/smarty/libs/Smarty.class.php');
readfile('C:/wamp/www/smarty/templates/index.tpl');
$smarty = new Smarty;
$smarty->setTemplateDir($base_path.'C:/wamp/www/smarty/templates');
$smarty->setCompileDir('C:/smarty/templates_c');
$smarty->setCacheDir('C:/smarty/cache');
$smarty->setConfigDir('C:/wamp/www/smarty/configs');

$smarty->assign('name','fish_boy!');

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


Also, I seen a topic which had an organized method to structure my smarty project. This is the topic.

http://www.smarty.net/forums/viewtopic.php?t=6892&highlight=wampserver

I wanted to know if this is an easier way to create my structure instead of the method im using now?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Thu Apr 05, 2012 12:00 pm    Post subject: Reply with quote

My mistake. Thisone was also wrong

Must be
Code:
$smarty->setTemplateDir('C:/wamp/www/smarty/templates');
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Apr 05, 2012 2:53 pm    Post subject: Reply with quote

Why do the following paths not include "/wamp/www" like the rest of them?

Quote:
$smarty->setCompileDir('C:/smarty/templates_c');
$smarty->setCacheDir('C:/smarty/cache');


Have you tried the testInstall() ?

http://www.smarty.net/docs/en/api.test.install.tpl
Back to top
View user's profile Send private message Visit poster's website
Note
Smarty n00b


Joined: 04 Apr 2012
Posts: 3

PostPosted: Thu Apr 05, 2012 10:58 pm    Post subject: Reply with quote

Sorry, I followed a tutorial that made it that way. I have fixed the paths to the way you guys suggested, and now everything works and I can get on localhost again. Thankyou Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP