|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Nov 24, 2004 10:38 am Post subject: |
|
|
$template_dir has to be readable by the webserver's uid ("www" in your case)
$config_dir has to be readable by the webserver's uid ("www" in your case)
$compile_dir has to be writeable by the webserver's uid ("www" in your case)
$cache_dir has to be writeable by the webserver's uid ("www" in your case)
when trying to install something you should set
error_reporting(E_ALL); ini_set('display_errors', true);
in php to make sure you get all possible errors reported.
if you configure relative-paths for template_dir, compile_dir etc. (i.e. leave them to their default values), then these paths are relative to the cwd, which is most likely the directory where the called php-page is in.
i really don't see what's so hard in all that. |
|
Back to top |
|
octane Smarty Regular
Joined: 22 Nov 2004 Posts: 35
|
Posted: Wed Nov 24, 2004 10:46 am Post subject: |
|
|
OK, I think brute force has triumphed over logic.
At some point, I've been flicking through permission types on the aforementioned folders and I've got the damned thing working.
However .. there is an interesting caveat to this minor victory: it only works when calling the extend class directly from within the browser.
By adding the following lines of code outside the class:
Code: | $classSmarty = new SmartyTemplate();
$classSmarty->display('login.tpl'); |
This triggers the required template file [albeit in the absence of the appropriate style sheets, but that's as expecting .. but I digress]
But if I call the extend class from the index page, I get the following error:
Code: | [Wed Nov 24 10:38:44 2004] [error] PHP Fatal error: Cannot instantiate non-existent class: smartytemplate in <pathremoved>/index.php on line 12 |
The index page: 'index.php' in its entirety is as follows:
Code: | <?php
// define directory paths
define ('ROOT_DIR', '<pathremoved>/applications/');
define ('COMMON_DIR', '<pathremoved>/applications/common/');
define ('CLASSES_DIR', '<pathremoved>/applications/common/classes/');
define ('INCLUDES_DIR', '<pathremoved>/applications/common/includes/');
// include Smarty template class
require (CLASSES_DIR . 'ui/smarty/smarty.inc.php');
$classSmarty = new SmartyTemplate();
$classSmarty->display('login.tpl');
?> |
You may say that by not providing a full path for you to inspect, the error might lie there. However, if the path was incorrect, I would have found an appropriate error message in the logs. Suffice to say, I didn't, so I'm confident the paths are correct.
I think I'm getting there... |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Nov 24, 2004 10:49 am Post subject: |
|
|
i just hope your '<path_removed>' doesn't start with 'http://' |
|
Back to top |
|
octane Smarty Regular
Joined: 22 Nov 2004 Posts: 35
|
Posted: Wed Nov 24, 2004 10:51 am Post subject: |
|
|
messju wrote: | $template_dir has to be readable by the webserver's uid ("www" in your case)
$config_dir has to be readable by the webserver's uid ("www" in your case)
$compile_dir has to be writeable by the webserver's uid ("www" in your case)
$cache_dir has to be writeable by the webserver's uid ("www" in your case)
when trying to install something you should set
error_reporting(E_ALL); ini_set('display_errors', true);
in php to make sure you get all possible errors reported.
if you configure relative-paths for template_dir, compile_dir etc. (i.e. leave them to their default values), then these paths are relative to the cwd, which is most likely the directory where the called php-page is in. |
That's really helpful, thanks!
I'll copy & paste that into my discovery documents for this project.
messju wrote: | I really don't see what's so hard in all that. |
Maybe adding that to the documentation might help.
Either non of the above is mentioned in the documentation or it isn't covered as literally and as thoroughly. |
|
Back to top |
|
octane Smarty Regular
Joined: 22 Nov 2004 Posts: 35
|
Posted: Wed Nov 24, 2004 11:08 am Post subject: |
|
|
messju wrote: | I just hope your '<path_removed>' doesn't start with 'http://' |
That's a very good point, because that's exactly what I was doing.
boots wrote: | ... try using absolute paths if at all possible. |
Now, when I was poking around on the PHP.net website, I found this:
Quote: | fopen() binds a named resource, specified by filename, to a stream. If filename is of the form "scheme://...", it is assumed to be a URL and PHP will search for a protocol handler (also known as a wrapper) for that scheme. If no wrappers for that protocol are registered, PHP will emit a notice to help you track potential problems in your script and then continue as though filename specifies a regular file. |
But my interpretation of the advice from Boots was to include the full path!
Quite.
Anyway, having removed the: 'scheme://...' I'm still getting the same errors:
Code: | [Wed Nov 24 11:04:00 2004] [error] PHP Warning: Smarty error: unable to read resource: "login.tpl" in /usr/local/php/lib/php/Smarty-2.6.6/libs/Smarty.class.php on line 1088
[Wed Nov 24 11:04:00 2004] [error] PHP Fatal error: Smarty error: the $cache_dir 'directories/cache/' does not exist, or is not a directory. in /usr/local/php/lib/php/Smarty-2.6.6/libs/Smarty.class.php on line 1088 |
|
|
Back to top |
|
octane Smarty Regular
Joined: 22 Nov 2004 Posts: 35
|
Posted: Thu Nov 25, 2004 4:51 pm Post subject: |
|
|
I'm still no further forward in getting Smarty to work.
Clearly the installation documentation needs revising and massively simplifying so that it's easier to understand.
I'm sure that there are many, many people like me who aren't seasoned CLI aficionados but do want to make a serious fist of PHP and by extension, Smarty.
In it's current form, I don't see that being possible. Simply installing Smarty is a cumbersome, error-prone process.
Maybe things will improve with time. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Nov 25, 2004 5:00 pm Post subject: |
|
|
octane wrote: | Maybe things will improve with time. |
maybe your skills will improve with time (certainly they will).
then installiing and operating smarty will become damn easy.
sorry, but when you honestly use "http://..." while everybody is talking about filenames you seem to have quite a long way to go. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Nov 26, 2004 12:28 am Post subject: |
|
|
Hi octane.
Yes, any documentation can be made better but I think your expectations might be a little high. Smarty is a PHP library: sure, one of its goals is to make template designers lives simpler but the person doing the PHP part still has to be familiar with PHP before being at a point where they might profitably use Smarty. So yes, as a library it has expectations of its environment but they shouldn't be overwhelming to grasp: Smarty needs two places in the file system to read/write from and two to read from and it needs you to tell it where they are. How you set them up in terms of your server is very dependant on your platform so it really falls outside the scope of the Smarty docs. What is a provided is meant as a guide for the clueful and (hopefully) as a starting point for those who are just getting up to speed. Unfortunately, it is not always enough but the usual remedy is to become more familiar with how your platform works before jumping into a library like Smarty. The good news is that it is well worth the effort as you are likely going to run into related issues all the time and surprisingly, it doesn't take a lot to learn the key elements that you will need.
I hope the next time you decide to try things go a lot smoother.
Cheers. |
|
Back to top |
|
|
|
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
|
|