|
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 |
prl77 Smarty n00b
Joined: 06 Sep 2012 Posts: 2
|
Posted: Thu Sep 06, 2012 6:00 pm Post subject: set dirs in include |
|
|
I would like to have a single setDirs script which uses the setCompileDir, etc functions to set all dirs. I would like to require this script from all my other scrips so I don't have to set dirs in each script individually. This is not working.
Code: |
<?php
//smartyTest.php
require_once('libs/Smarty.class.php');
require_once('libs/smartyDirs.php');
$smarty = new Smarty();
$smarty->testInstall();
?>
|
Code: |
<?php
//smartyDirs.php
require_once('Smarty.class.php');
$smarty = new Smarty();
$smarty ->setTemplateDir('./templates')
->setCompileDir('./templates/smartyDirs/compile')
->setCacheDir('./templates/smartyDirs/cache/')
->setConfigDir('./templates/smartyDirs/configs/');
?>
|
If I set the dirs in the smartyTest.php script, it works, but requiring it from another script does not. Is that possible?
Thanks! |
|
Back to top |
|
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Thu Sep 06, 2012 7:52 pm Post subject: This is not the way to configure your Smarty |
|
|
No, This does not work at all.
Your line #3,4 will overwrite the configurations you have in smartyDirs.php, and it results as if you have no settings configured at all.
You probably wanted:
Code: | <?php
//smartyTest.php
require_once('libs/smartyDirs.php');
?> |
only. |
|
Back to top |
|
prl77 Smarty n00b
Joined: 06 Sep 2012 Posts: 2
|
Posted: Fri Sep 07, 2012 10:25 pm Post subject: |
|
|
Thank you @bimal,
I did as you suggested, but it still uses the default dirs. |
|
Back to top |
|
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Fri Sep 07, 2012 11:18 pm Post subject: |
|
|
Here is my working configuration for version 3.1-DEV:
- Full path assignment
- No method chaining (independent assignment)
Code: |
require_once(__THIRD__.'/smarty/Smarty.class.php');
$smarty = new Smarty();
# Avoid the risk of files being over-written when using common directory for all subdomains
$smarty->compile_id = preg_replace('/[^a-z]/is', '', $_SERVER['SERVER_NAME']);
$smarty->compile_dir = __TEMP__.'/smarty_compiles';
$smarty->cache_dir = __TEMP__.'/smarty_cache';
# Updates for 3.1RC1
$smarty->addPluginsDir(__BASE__.'/plugins');
$smarty->addPluginsDir(__FRAMEWORK__.'/plugins');
$smarty->setTemplateDir(__BASE__.'/templates');
$smarty->setConfigDir(__BASE__.'/configs');
|
Hope this helps you as a reference. |
|
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
|