Re: [SMARTY] Checking for nonexistent array keys in template

From: Date: Wed, 04 Sep 2002 13:26:16 +0000
Subject: Re: [SMARTY] Checking for nonexistent array keys in template
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5923@lists.php.net to get a copy of this message
On 4 Sep 2002 at 11:38, vlcc69jfbo001@sneakemail.com wrote: > > HTH, > > Ferdinand > > That's great - thanks for the tips. > > Hope you don't mind me asking - I have another problem with some code that > Peter Bowyer posted a while ago for using templates in strings: What about mailing this to smarty-general@lists.php.net? Maybe there are more guys out there who have the same problem or who know the answer. I also try to read every message and help where I can. > on 26/8/2002 12:31 pm, Peter Bowyer peter@mapledesign.co.uk wrote: > > > ============== > > function eval_string($var) > > { > > > > if (!isset($var)) { > > $this->trigger_error("eval: missing 'var' parameter"); > > return; > > } > > if($var == '') { > > return; > > } > > > > $this->_compile_template("evaluated template", $var, $source); > > #print htmlspecialchars($var) . '<br>Source: ' . > > htmlspecialchars($source) . '<br>'; > > ob_start(); > > eval('?>' . $source); > > $evaled = ob_get_contents(); > > ob_end_clean(); > > return $evaled; > > } > > =============== > > I've been using this in my Smarty class extension and it works fine, apart > from one problem. I'm building templates for email, and as each message has > separate plain text and HTML templates, I have two smarty instances which > compile their templates separately. I process the plain text template first, > then the HTML template, but the class gives me back the compiled text from > the plain template! These are completely separate template strings and > Smarty instances, but I'm wondering if it's something to do with Smarty's > caching - i.e. It notices that the templates are both submitted under the > name "evaluated template", and returns the cached version for the second > request. Is that likely? If so, how can I tell Smarty not to cache this > page? I'm not worried about speed as none of it needs to be real-time. > > Thanks, > > Marcus > -- > Marcus Bointon > Synchromedia Limited: Putting you in the picture > > XXXXXXXXXXXXXXXXXXXXXXXXX | http://www.synchromedia.co.uk > > > You can try to use different cache_id's or simply set $smarty- >caching = 0 before calling display() or fetch(). By the way: You are passing the same variables to different templates - HTML and plain text - don't you? Why do you need two Smarty instances? Won't this work? $smarty = new Smarty() $smarty->caching = 0; $smarty->assign(...); $html = $smarty->fetch('html_mail.tpl'); $plain = $smarty->fetch('plain_mail.tpl'); -- Ferdinand Beyer <fbeyer@clickhand.de>

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