From: Alain F. <al...@va...> - 2001-03-28 22:41:05
|
Hello, Although the developers would probably be able to better answer your questions, I'll give it a try. Find my answers in the quote below. > The above would stay cached for 60 minutes, but would the > following have to > be reparsed each run? > > index.tpl (unchanged) > > --index.php-- > ... > $smarty->assign("Name",$name_from_query); > $smarty->display("index.tpl"); > ... > > How about > ... > $smarty->display($template_name_from_database); > // instead of hardcoded template string like index.tpl > ... > > If the above would be cached, then Smarty should be considered > VERY closely. > Alain, can you find out about this? Actually, the template engine involves two steps here... the "smarty language" templates, e.g. HTML markup with special Smarty tags, are COMPILED into native PHP code first, and then included into the calling file. This means that you actually have two "buffers" you can control: the compilation, and the real caching of the pure HTML file with data in it. Compilation can be handled dynamically, e.g. Smarty can check if a file needs re-compilation because of changes or not, but you can also de-activate compilation completely once you have your final template versions. This then gives a drastic performance boost as the parsing doesn't take place anymore. In addition to this, you have the "real" concept of caching, e.g. storing static versions of the files as pure HTML. Now to your question if your database example would be cached ? Yes, I suppose so, as Smarty's caching mechanism somehow relies on an MD5 checksum it creates from the template name. However, be sure not to mistake caching of output and compiling of templates. On a side note, what's the difference for PHP if you "hard-code" a function argument, or read it from a database ? :) function("test") and function($bla) are exactly the same to php as long as $bla=="test", so there's no difference at all between "hard-coding" the template name or getting it out of a database... or am I overlooking something here ? ;) > > 2. How should phpWebSite use templates? We definately need to rely on > style sheets first !! Assuming we are, how should we look at templates? How about using variable (templated??) style sheets ? :) I've done that already. Something like: H1 {font-family: <?echo $fonts?>} is absolutely possible. I wonder if this could be done using smarty... yes, I suppose so. That way the look&feel of the site could be completely stored in the database, too, somehow using a table that associates the various styles that are used with their values, and an easy admin interface to change these values. > > I'm thinking of a simple template for the entire site, which would adjust > the placement of blocks (i.e. nav bar, title, polls, articles, > etc.). These > blocks would have their own HTML in the phpWebSite plug-in itself OR a > separate plug-in template file. The problem with this is whether or not > caching would be done by Smarty. I don't think it could cache this > arrangement, but maybe it doesn't need to. Don't forget in this regard that you can have multiple Smarty instances doing the parsing/compiling etc, and that you can set the "cache" and "recompile" options on a per-instance basis .... this basically means that you can somehow switch on/off compiling and caching quite easily. > > The fundamental question is what are we looking to accomplish with > templates? I don't think phpWebSite is designed to be templated the way > Smarty was conceived--that is on a file by file basis, but I > still think it > can be used to accomplish what we want, maybe even in its present > form. But > what do we want--that is the question? > I don't really follow you here... what exactly do you mean when you say that Smarty was designed to work on a file by file basis ? Thanks, and talk to you soon ! |