Re: [SMARTY] Basic question about insert

From: Date: Wed, 16 Jul 2003 22:58:39 +0000
Subject: Re: [SMARTY] Basic question about insert
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-9913@lists.php.net to get a copy of this message
At 00:27 17/07/2003 +0200, messju mohr wrote:
"$smarty.server.HTTP_REFERER" is cached also (all parameters to insert a cached). this means getGreeting always uses the same value. remove the parameter from the {insert}-tag and use $_SERVER['HTTP_REFERER'] inside your getGreeting-function instead.
Is it possible (and if yes how) to pass an object to insert ? Let's say I have a class that manages some database access stuff Among these database access stuff is a set of two function devoted to see "how many people are currently online". The result must not be cached so I have index.php [...] include 'include/smarty/lib/display.class.php'; include 'include/smarty/lib/insert.fonctions.php'; [...] $mydisplay = new DisplayClass; [...] then in insert.fonctions.php function insert_getNbreVisiteurs() {
        $myvisiteur = new DisplayClass;
         $myvisiteur->update_frequency = 3;
        $myvisiteur->timeout = 5;
        $nombre = $myvisiteur->getNbreEnLigne();
        if ($nombre == 1) {
           return '<strong>'.$nombre.'</strong> visiteur en ligne.. vous !';
           } else {
           return '<strong>'.$nombre.'</strong> visiteurs en ligne';
           }
} and in the tpl file {insert name="getNbreVisiteurs"} This works but this is stupid because I create two version of the object. How can I pass the current object ($mydisplay = new DisplayClass) to my insert function passing through the caching system. Thanks in advance Luc

« previous php.smarty.general (#9913) next »