?
Solved

help with smarty installation

Posted on 2005-04-05
12
Medium Priority
?
514 Views
Last Modified: 2012-06-27
Hi, I am trying to install and test smarty on a shared hosting account and I am a little lost. I tried to follow the instructions on this page: http://smarty.php.net/quick_start.php but the hello {$name} sample page doesn't work. I must have the directories defined incorrectly.

I have installed the libs directory under my docroot (/www) in a directory named smarty.

It is recommended to create the template and cache directories outside the doc root. So I created a directory /smarty (on the same level as /www) and created the subdirectories there.

So I have:

/smarty/templates
/smarty/templates_c
/smarty/configs
/smarty/cache

and

/www/smarty/libs

I created the sample template and put it in the /smarty/templates directory! And the following is my version of the index.php file:

<?php

// put full path to Smarty.class.php
require($_SERVER['DOCUMENT_ROOT'] . '/smarty/libs/Smarty.class.php');
$smarty = new Smarty();

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

$smarty->assign('name', 'Me');
$smarty->display('index.tpl');

?>
 
The above doesn't really make sense to me, but it was all I could come up with. I get the error that it can't read the template. Surely because I have incorrectly defined the directory.

Can someone help?

Thanks!
0
Comment
Question by:alpineer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
12 Comments
 
LVL 6

Expert Comment

by:alextr2003fr
ID: 13708979
did you add smarty directory to your include_dir in the configuration? if not then it could be the problem
0
 

Author Comment

by:alpineer
ID: 13709065
Sorry, but I don't understand your question. In the configuration of what?
0
 
LVL 6

Expert Comment

by:alextr2003fr
ID: 13709133
its a path problem, and maybe it will be easier if you can declare the full path to smarty in your php.ini by adding it to include_dir directories, also see if you define SMARTY_DIR as said in the documentation, define("SMARTY_DIR","/your/path/to/smarty/");
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:alpineer
ID: 13709202
I am on a shared hosting account so I don't think I have access to php.ini. I was just trying to follow the instructions in this quick setup page I mentioned. I also don't think I can do the chown they mention. I did do the chmod to 775.
0
 
LVL 25

Expert Comment

by:Marcus Bointon
ID: 13709214
In the error message that says it can't find the template, it should reveal the path it's looking in, and possibly your include path too.
0
 
LVL 11

Accepted Solution

by:
matt_mcswain earned 1000 total points
ID: 13709221
Just give smarty full paths.

$smarty->template_dir = $_SERVER['DOCUMENT_ROOT'] .'/smarty/templates';
$smarty->compile_dir = $_SERVER['DOCUMENT_ROOT'] .'/smarty/templates_c';
$smarty->cache_dir = $_SERVER['DOCUMENT_ROOT'] .'/smarty/cache';
$smarty->config_dir =$_SERVER['DOCUMENT_ROOT'] . '/smarty/configs';
0
 

Author Comment

by:alpineer
ID: 13709330
The documentation says you should either define SMARTY_DIR or provide a full path. I think I am doing the latter by:

require($_SERVER['DOCUMENT_ROOT'] . '/smarty/libs/Smarty.class.php');

No?

0
 
LVL 6

Assisted Solution

by:alextr2003fr
alextr2003fr earned 1000 total points
ID: 13709400
the problem is that your root and smarty are on same levels so try to move one level up from your root to have the right path maybe you should do something like dirname($_SERVER['DOCUMENT_ROOT']) instead of $_SERVER['DOCUMENT_ROOT'] :
$smarty->template_dir = dirname($_SERVER['DOCUMENT_ROOT']).'/smarty/templates';
$smarty->compile_dir = dirname($_SERVER['DOCUMENT_ROOT'])...
etc etc
0
 
LVL 11

Expert Comment

by:matt_mcswain
ID: 13709444
Yeah, you're right, it's one up.
0
 

Author Comment

by:alpineer
ID: 13709591
Bingo!!! That worked.

Though at first I got an error that the directory templates_c must be writable by the web server process. I guess this is because I can't do the chown as per the instructions. I temporarily chmod'ed the directory to 777 and that works, but is this safe? If not how do I get around this?
0
 
LVL 25

Expert Comment

by:Marcus Bointon
ID: 13714600
If you can't use chown (why can't you?) and the file is not currently owned by the web server as either owner or group, you have no choice but to use chmod 777.
0
 

Author Comment

by:alpineer
ID: 13714686
Thanks to eveyone for the replies. I just found the smarty forums so I will follow up there. In any event, your help got me started. I was even able to create a looping section! I am now a big fan of smarty.

0

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question