Jump to content


Photo

Smarty Engine | Newbie Questions


  • Please log in to reply
No replies to this topic

#1 JustinK101

JustinK101
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego, California, US

Posted 09 June 2006 - 08:34 AM

Hello all, I just found out about smarty and looking forward to using it. I do have a few questions. Here is how I have smarty setup.

This is the full path to the smarty engine and libs directory. This directory is not web accessible.

/home/username/smarty/

The next directory 'smarty_templates' will hold all my of projects, each project will have it's own folder and associated: templates_c, templates, config, and cache folder. This is web accessible, obviously!

/home/username/public_html/smarty_templates/

I have multiple projects which use smarty but I want to keep them seperate. Is this the right way of going about doing it? I.E. making a 'smarty_templates' directory then having a 'project_1' folder which has its own 'templates_c', 'templates', 'cache', and 'config' folder. Then another project, 'project_2', which has its own 'templates', 'templates_c', 'cache', and 'config' directories.

The directory strucuture will look like this:

smarty_templates
     project_1
          templates_c
          templates
          cache
          config
     project_2
          templates_c
          templates
          cache
          config

My second question, how can I make it easier to reference the smarty class and the associated templates associated with a project?

Currently I have to type the full path name for every template which is kind of a pain in the butt. This full path is going to be global, every project will use them, so I want to set them to default for every project without typing the entire paths as I show below.

require('/home/username/smarty/libs/Smarty.class.php');
$smarty = new Smarty();

$smarty->template_dir = '/home/username/public_html/smarty_templates/project_1/templates';
$smarty->compile_dir = '/home/username/public_html/smarty_templates/project_1/templates_c';
$smarty->cache_dir = '/home/username/public_html/smarty_templates/project_1/cache';
$smarty->config_dir = '/home/username/public_html/smarty_templates/project_1/configs';

Is there a way I can hard code, set a global variable for these full paths so I can simply do:

require('Smarty.class.php');
$smarty = new Smarty();

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

You see how much eaiser and better that looks.

Lastly, what is the config directory for anyway? I mean this directory will be defined for every project, so how does it work?

Thanks Guys!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users