|
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 |
DeyV Smarty Rookie
Joined: 01 Jul 2003 Posts: 6 Location: Poland
|
Posted: Thu Oct 07, 2004 10:03 pm Post subject: poor smarty_include_tpl_file |
|
|
I'm like work's with small templates for all classes (method from eZ publish - for all Content class we have one or more tpl)
This is very easy to programming end editing.
But.. in smarty I'm have one small problem with this method - time.
Scripts working very slow when I have iteration where I'm including other tpl files.
Maybe some hack can improve this method?
Or is time to rebuild structure of compiled files, and generate function with all tpl (all compile tpl will be included only once, and in iteration only use this function)?
Sorry for my language - English isn't native for me. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Oct 08, 2004 12:46 am Post subject: |
|
|
Including is a relatively expensive operation. The same holds true for PHP, btw, but it is even moreso with Smarty. A good PHP accelerator can help you tremendously. Another help is to emply Smarty's caching features. Once your site is developed and your templates aren't changing anymore, you may want to turn off any checks for compilation such as setting $smarty->compile_check=false.
If you are doing includes recursively, you can get a big speedup by using this technique: http://www.phpinsider.com/smarty-forum/viewtopic.php?t=291
HTH |
|
Back to top |
|
DeyV Smarty Rookie
Joined: 01 Jul 2003 Posts: 6 Location: Poland
|
Posted: Fri Oct 08, 2004 9:18 am Post subject: |
|
|
Ok. It maybe can help.
But what you thing's abut somthing, what I'was see in the WACT templates system. (the 'function from all templates' )
Maybe somthing that can help
row.tpl
Code: | <td><tr> {$name}</tr></td> |
table.tpl
Code: | <table>
{section .... }
{include_once file="row.tpl" }
{/section}
</table>
|
after "compilation" can look that (in the pseudo code)
row.ctpl.php
[php:1:ffc70dc620]
<?php
function smarty_tmp_row_tpl( $_tpl_vars )
{ ?>
<td><tr> <?= $_tpl_vars['name'] ?></tr></td>
<?php
} ?>
[/php:1:ffc70dc620]
table.ctpl.php
[php:1:ffc70dc620]<?php
function smarty_tmp_table_tpl( $_tpl_vars )
{ ?>
<table>
<?php
foreach( $_tpl_vars[ 'ble' ] as $row )
{
smarty_tmp_row_tpl( $_tpl_vars + $row );
}
?>
</table>
<?php
//end of the file
smarty_include_once_tpl_file( 'row.tpl' )
?>[/php:1:ffc70dc620]
From my small test I'm know, that 1 include and many run function from file is much better than many includs.
What You think about it? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Oct 08, 2004 9:04 pm Post subject: |
|
|
You are correct about inlining, at least in this instance. The thread I included in the last post includes a plugin that basically lets you do the same thing. |
|
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
|