Samrty Templation Installtion and Configuration

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lisamarie_tt
Forum Commoner
Posts: 32
Joined: Fri Jul 15, 2005 8:20 am

Samrty Templation Installtion and Configuration

Post by lisamarie_tt »

I am having some difficulties getting smarty to work.

1. I'm not certain where to place the smarty folder.
2. I'm not sure where i have to create the templates, templates_c, cahce and configs folders. Or if I need to create them at all.
3. I'm not sure as to what configurations are to be done to the php.config file and php.ini file if any.

I looked at the online installation help files but i am still stuck. For my current setup I have extracted the Smary files into a Smarty folder in htdocs folder.
I created the templates, templates_c, cahce and configs folders in my working directory.
I tried running the follwoing test:

The template file: resides in the template folder

Code: Select all

{* Smarty *}

Hello, {$name}!
The index.php file: resides in my working folder or application root

Code: Select all

<?
include('../../Smarty/Smarty.class.php');

// create object
$smarty = new Smarty;

//set the smarty dir
$smarty->template_dir = 'templates/';
$smarty->compile_dir = 'templates_c/';
$smarty->config_dir = 'configs/';
$smarty->cache_dir = 'cache/';

//assign content
$smarty->assign('name','Ned');

//display content
$smarty->display('templates/index.tpl');
?>
I am getting the following errors when i access the index.php file

Warning: _parse_resource_name(C:\htdocs\Smarty\internals\core.get_include_path.php): failed to open stream: No such file or directory in C:\htdocs\Smarty\Smarty.class.php on line 1643

Fatal error: _parse_resource_name(): Failed opening required 'C:\htdocs\Smarty\internals\core.get_include_path.php' (include_path='.;c:\php4\pear') in C:\htdocs\Smarty\Smarty.class.php on line 1643
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Re: Samrty Templation Installtion and Configuration

Post by jmut »

See if you have your include paths correct...
And you don't need
$smarty->display('templates/index.tpl');
just
$smarty->display('index.tpl'); should be enough since you already defined where templates are....


Here is sample config...

Have project dir in htdocs somewhere

project/Smarty/ -> this is Smarty directory
project/templates/ -> this is where you place templates
project/templates_c/ -> this is where Smarty cache stuff -> should be writeable by your server running user


project/templates/index.html -> sample template and content following
{$test}

project/index.php -> the php that will run the templtate and its content

Code: Select all

<?php
error_reporting(E_ALL);
require_once('./Smarty/Smarty.class.php');

$smarty = new Smarty;
$smarty->debugging = true;
$smarty->assign('test','Hi there...If you see me it's working');
$smarty->display('index.html');
?>
lisamarie_tt
Forum Commoner
Posts: 32
Joined: Fri Jul 15, 2005 8:20 am

Post by lisamarie_tt »

Thanks for your suggestions.

I tried your fixes and the same errors are occuring:
Warning: fetch(C:\htdocs\LisaMarie\vehicleParser\Smarty\internals\core.get_microtime.php): failed to open stream: No such file or directory in C:\htdocs\LisaMarie\vehicleParser\Smarty\Smarty.class.php on line 1142

Fatal error: fetch(): Failed opening required 'C:\htdocs\LisaMarie\vehicleParser\Smarty\internals\core.get_microtime.php' (include_path='.;c:\php4\pear') in C:\htdocs\LisaMarie\vehicleParser\Smarty\Smarty.class.php on line 1142


Do you have any other suggestions? Are there any other php configurations that should be made?
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

lisamarie_tt wrote:Thanks for your suggestions.

I tried your fixes and the same errors are occuring:
Warning: fetch(C:\htdocs\LisaMarie\vehicleParser\Smarty\internals\core.get_microtime.php): failed to open stream: No such file or directory in C:\htdocs\LisaMarie\vehicleParser\Smarty\Smarty.class.php on line 1142

Fatal error: fetch(): Failed opening required 'C:\htdocs\LisaMarie\vehicleParser\Smarty\internals\core.get_microtime.php' (include_path='.;c:\php4\pear') in C:\htdocs\LisaMarie\vehicleParser\Smarty\Smarty.class.php on line 1142


Do you have any other suggestions? Are there any other php configurations that should be made?
Well there is something wrong with the paths
do you have core.get_microtime.php file in this directory...
If not find the file...fix the path....enjoy
lisamarie_tt
Forum Commoner
Posts: 32
Joined: Fri Jul 15, 2005 8:20 am

Post by lisamarie_tt »

No i don't. Thks for the info.
Post Reply