|
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 |
terryjohnson Smarty Rookie
Joined: 03 Jan 2004 Posts: 9 Location: Chatham, ON, Canada
|
Posted: Sat Jan 03, 2004 5:21 pm Post subject: Precompiled templates |
|
|
Is it possible to pre-compile templates?
I know this defeats some of the advantages of Smarty, but it would make it easier to operate on a production site where safe_mode is on, which is the case for the majority of PHP web hosts, and quite useful even when running a on dedicated box. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat Jan 03, 2004 5:51 pm Post subject: |
|
|
if you don't want to compile on a production-server you can set $smarty->compile_check to false and upload the contents of templates_c manually. this should work. |
|
Back to top |
|
terryjohnson Smarty Rookie
Joined: 03 Jan 2004 Posts: 9 Location: Chatham, ON, Canada
|
Posted: Sat Jan 03, 2004 8:57 pm Post subject: |
|
|
Turning off compile is a good feature, but what I was asking was whether it is possible to do something from the command prompt like:
[user lib]$ php Smarty_Compile.php ./templates/foo.tpl
so that the template can be coded, compiled and deployed without having to have an reasonable replica of the production environment to play with? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat Jan 03, 2004 9:27 pm Post subject: |
|
|
there is no public api to compile a template. the simplest way is to call $smarty->fetch($tpl) or $smarty->fetch($tpl, $cache_id, $compile_id). |
|
Back to top |
|
terryjohnson Smarty Rookie
Joined: 03 Jan 2004 Posts: 9 Location: Chatham, ON, Canada
|
Posted: Wed Jan 07, 2004 5:09 pm Post subject: |
|
|
OK I figured out how to do it by having a short php script in my development environment which can be passed template names as an argument:
Code: | <?php
/**
* Smarty Compile
**/
require_once('Smarty.class.php');
$smarty =& New Smarty;
if (isset($_REQUEST['template'])) {
$smarty->display($_REQUEST['template'].'.tpl');
} else {
echo 'No template specified';
}
?> |
Am I right in thinking that if I set compile to false in the production environment I can do away with the /templates folder and Smarty_Compiler.class.php altogther? |
|
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
|