AW: [SMARTY-DEV] Replacing include with include_once in Smarty::fetch()?
| From: | Matthias Pigulla | Date: | Thu, 16 Sep 2004 11:18:55 +0000 |
| Subject: | AW: [SMARTY-DEV] Replacing include with include_once in Smarty::fetch()? | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-2570@lists.php.net to get a copy of this message | ||
Hello everyone,
> -----Ursprüngliche Nachricht-----
> Von: boots [mailto:jayboots@yahoo.com]
> Gesendet: Donnerstag, 16. September 2004 03:10
> This is an interesting idea...but are you using a PHP
> accelerator? That should speed-up includes considerably.
> Further, the scenario you describe sounds hardly typical and
> even if you are generating many emails in bulk (hmmmmmmmmmm)
> I would assume that you wouldn't be facing many concurrent
> users but rather simply having to sporadically endure a
> longer running process.
No, I'm not running an accelerator. As long as my problems are home-made, I'll try to
solve them by better coding and better architecture - I can always use "external" tools
later on ;). Besides that, maybe an accelerator can speed up the include - but does it scale up?
Maybe I don't see the point, but (as long as the template does not need to be recompiled) my
approach just takes one include, regardless of the number of iterations. The same aspects apply to
memory usage.
> In other words, optimizing here seems
> unwarranted.
Yes, I know, and I did not see any real benefits for "normal" users before. However, I
wanted to share the idea with you and was amazed that you seem to have use for it:
> cool compiler plugin that you can find in this thread
> http://www.phpinsider.com/smarty-forum/viewtopic.php?t=291
> (which is on recursion, but you need not use it recursively).
The concept is exactly the same, if you set it up right it should be possible just to {include
file="the_template_itself"}. That could turn into a include_once and real PHP level
recursion.
messju used a compiler function for injecting the "function" strings, I used a postfilter
as I want the function to span the whole template. I have hacked into Smart::fetch() what messju did
as "smarty_compiler_fun".
As messju already pointed out, his plugin may become a maintenance problem; maybe moving it into the
Smarty class itself might help a little. The only thing one would have to think about a little is
correctly setting up all variable scopes...
> I don't mean to be impolite, but I sure hope this isn't some
> spam related thing ;)
No, I spend so much time fighting spam I'd never write such software ;) - Honestly, it's a
(opt-in :) newsletter mailing system.
Matthias