Re: [SMARTY] user input via form - which strategy?
| From: | Ferdinand Beyer | Date: | Mon, 05 Aug 2002 08:15:28 +0000 |
| Subject: | Re: [SMARTY] user input via form - which strategy? | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-5582@lists.php.net to get a copy of this message | ||
On 4 Aug 2002 at 19:21, eclectic02002@yahoo.de wrote:
> Hello,
>
> During the last 4 Weeks I developed a small CMS for a business
site. The
> CMS works like a charm. :)
> When I integrated Smarty for the front end I was not totally aware
about
> the consequences and so I probably made a big mistake yet I have
a week
> or so to go and with a little help from this list I might find my
> way....
>
>
> This is what the template has to do:
>
> The template has to show a menu which changes accordingly to
the
> languageset.
>
> And it shows the content accordingly to the chosen article.
>
>
> My setup looks like this:
>
> I have just one large index.php file that handles all the logic and
> chacks user input variables. The template is devided into 2 files for
> header and content.
>
> -First it gets all of the available menus from my database.
> -Then it checks which article the visitor is calling and makes the
right
> queries.
> I only fetches the requested (via post variables) article from the
> database or if the user wants all articleheaders displayed (request
via
> post variables) it gets those informations.
>
> -The template does now show all the data as is with loops for the
menu
> and if clauses to handle the layout differences between article and
> articleheaders.
>
> Without caching enabled this works like a charm and is even fast
but I
> wonder if this can be cached at all?
>
> I want to cache the site on the whole but I don't understand how it
is
> possible??
>
>
> John Waldorff
>
>
>
>
>
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Hi,
I guess that you know how to configure Smarty to cache templates.
See the docs for this. It is mainly controlled with the
Smarty::$caching variable. If you have contents on your page that is
always changed and should not be cached, use {insert} functions for
this (see the docs).
I recommend you to pass the $cache_id parameter to
Smarty::display() so that all the different views of your templates are
chached seperately. For example: If the page displayed by Smarty
depends on the article's id ($article_id) and the chosen language
($lang), create a cache id string consisting of $article_id and $lang:
<?php
define('SMARTY_CACHE_ID', "$article_id-$lang");
$smarty = new Smarty();
$smarty->display('index.tpl', SMARTY_CACHE_ID);
?>
Now every requested page with a different $article_id / $lang
combination gets cached seperately. You can easily extend
SMARTY_CACHE_ID if your page view depends on more variables.
In order to support the article index view, set $article_id to 'index' if
there is no $article_id passed.
I hope that helps - have some fun!
--
Ferdinand Beyer
<fbeyer@clickhand.de>