Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

poor smarty_include_tpl_file

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
DeyV
Smarty Rookie


Joined: 01 Jul 2003
Posts: 6
Location: Poland

PostPosted: Thu Oct 07, 2004 10:03 pm    Post subject: poor smarty_include_tpl_file Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Oct 08, 2004 12:46 am    Post subject: Reply with quote

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
View user's profile Send private message
DeyV
Smarty Rookie


Joined: 01 Jul 2003
Posts: 6
Location: Poland

PostPosted: Fri Oct 08, 2004 9:18 am    Post subject: Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Oct 08, 2004 9:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP