Installation, SMARTY_DIR and directories

From: Date: Mon, 24 Jun 2002 02:55:05 +0000
Subject: Installation, SMARTY_DIR and directories
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4986@lists.php.net to get a copy of this message
Having just installed Smarty there are some apparent inconsistencies (at least unexpected behaviours) that I would like to comment on regarding its use under a custom directory structure. These are areas that I feel could be better documented in the installation section of the manual, particularly as I notice similar problems from others mailing here. After first installing, setting permissions etc... on the default configuration (everything, including index.php in the Smarty directory), and checking that the demo page loads correctly, I then setup the following structure and (as per the ONLY required modification in the manual) set the SMARTY_DIR constant to point at the "Smarty" directory shown here. public_html -> includes -> Smarty -> configs index.php -> plugins -> cache -> templates -> templates_c This is where things went bad... the demo no longer ran, and the install guide is not so helpful, although clearly Smarty was not finding templates... and so therefore the problem was path related. My first understanding of the SMARTY_DIR constant is that this simply points at the main Smarty directory, from where all other smarty paths are referenced... this is in keeping with first understanding of the comments within the Smarty.class.php file where, next to the var settings for the directory paths it says "(relative to Smarty directory)", which I assumed to apply to all such paths. THIS IS NOT THE CASE, it ONLY applies to the last. With the exception of that (plugins), all other such path settings are relative to the calling document, index.php in the example above. Locating this at the document root, pointing SMARTY_DIR at Smarty and making no other changes is, Smarty EXPECTS to find the following: public_html -> includes -> Smarty -> plugins index.php -> configs -> templates -> templates_c -> cache (not sure about this one, here or under Smarty) That is that templates, templates_c, configs and possibly(??) cache should all now be sub-directories of the document root, in this case, public_html. This behaviour threw me for quite a while but, although I now see the logic of it, the "apparently odd" nature of the bahaviour could be attributed to my unfamiliarity with Smarty AND an area in the manual that COULD be improved upon. Also (not tested), the implication here is that where a site structure employs different folders for each section of the site, there would be a need to duplicate the templates, templates_c, cache and configs directories for each folder where a script that makes use of smarty is located. A better solution would be to setup constants for each of these directories and to then initialise the directory vars to those constants (excuse the line wrap!!)... define ( "SMARTY_TEMPLATES_DIR", $_SERVER ['DOCUMENT_ROOT'] . "/templates/"); and then, in Smarty.class.php var $templates_dir = SMARTY_TEMPLATES_DIR; And so on for the others needed.... It seems important however NOT to handle initialisation of plugins_dir in this way since this one NEEDS to be relative to the Smarty directory itself. Aside from this installation confusion/glitch, I like (very much) what I see here and look forward to integrating it with my future web development work. I hope though that the above remarks are seen as constructive and also that they perhaps help others who have had similar initial problems to my own in getting Smarty setup to work in their desired hierarchies. Regards Rob Schumann

« previous php.smarty.general (#4986) next »