Re: general question about smarty
| From: | Wolfram Kriesing | Date: | Wed, 23 May 2001 17:10:24 +0000 |
| Subject: | Re: general question about smarty | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-800@lists.php.net to get a copy of this message | ||
the caching of built html pages i see as a very interesting feature of
smarty indeed
> > 1. Is it a standard, that i can also use when i switch to another
> > language, such as java (jsp, python, ...), or is there a standard
coming
> > up?
>
> I have not seen any cross-language template standards...
> Also I don't think so Smarty will be such a language in the *near*
future
i was looking at w3c-pages and in general on the net and couldnt find
any positive result either, which i think is :-(
i know there is smarty (and others) for php, something for perl,
velocity for java-world
but no standard
> Abstraction. You have pieces of codes you use everywhere...
> You can put them in functions or classes, but (see the next answer)
that's what i do anyway, look at my question No. 4
> > 3. Why is it better to use "{SMARTY_VARIABLE}" instead of "<?php
> > print($variabelName) ?>", if i still am limited to use php behind,
> > because smarty only runs on php, or am i wrong?
>
> It is much easier for a designer to learn the {$VAR} syntax, and
well, is that so?
what is easier to learn about {$VAR} than <? print($var) ?> ?
> there can be less errors in the code. Smarty introduces no secholes,
> and if you disable the 'PHP code inside templates' features, designers
> can't break the server with bad templates...
only prints cant break things either, see my question 4
> > 5. is the webdesigner really free from seeing source code, if he now
> > gets to see another scripting language instead of php, the smarty
> > language?
>
> Designers can use any subset of the Smarty language.
> You can use it the 'FastTemplate' way, where only the
> {$VAR} syntax is enabled... Then why should you use
> Smarty instead of 'FastTemplate'? Eg. because Smarty
> beats FastTemplate in speed. :)
well still no real point against using {} instead of php-tags, i have
all the logic in the php file
that's how i currently do it:
i have one template file that looks like this (the general page layout)
---TEMPLATE.PHP---
<?php
if( !$mainNavi ) $mainNavi = "defaultpage.php";
if( !$subNavi ) $subNavi = "defaultpage.php";
if( !$content ) $content = "defaultpage.php";
?>
<html><body>
<table border="1">
<tr>
<td colspan="2">
<?php include($mainNavi); ?>
</td>
</tr>
<tr>
<td valign="top">
<?php include($subNavi); ?>
</td>
<td width="90%" valign="top">
<?php include($content); ?>
</td>
</tr>
</table>
</body></html>
then there is a page, that you can call directly, which simply includes
this template and defines the php-variables, mainNavi, subNavi, content,
if needed, otherwise they contain the defaultvalue as set in the
template
---SOMEPAGE.PHP---
<?php
include_once("config.php");
// *.exe.php does no echo/print, etc., sets all the variables
// that are used in the somepage.inc.php
// the logic itself could also go in this php-file here
include("somepage.exe.php");
// set the template element
$content = "somepage.inc.php";
include("template.php");
?>
that's it
and all the logic is in the exe-file or can even be in the SOMEPAGE.PHP,
if one wants
is the concepts so different?
the "$content" could even refer to another template which does the same
stuff over and over again
i am just trying to find the best solution for me and if it is smarty,
well i will be glad
Wolfram Kriesing