RE: [SMARTY] Why doesn't this work

From: Date: Sun, 10 Aug 2003 05:29:58 +0000
Subject: RE: [SMARTY] Why doesn't this work
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10022@lists.php.net to get a copy of this message
I'd suggest turning off caching while you're in development. $this->caching = false; It's quite possible your displaying a cached page where you previously had no value in 'errorMessage' and even though it's getting assigned to the template scope, smarty is just pulling up the cached page instead creating a new one. -mark ------------------------ Mark Priatel Iolog Web Communications www.iolog.com -----Original Message----- From: Avi Schwartz [mailto:avi@CFFtechnologies.com] Sent: Sunday, August 10, 2003 1:19 AM To: smarty-general@lists.php.net Subject: [SMARTY] Why doesn't this work Hi, I am just starting with both smarty AND php so I assume this is something stupid I am doing but I need help figuring this out. The problem I am having is that the function process_form() in test.php validates the input fields from the template's form and assigns an error message to $errorMessage. The popup debug console shows that the $errorMessage variable has the correct text, however when the template displays this variable it has no value so XX is displayed. What I am trying to figure out is what happened to the value of the $errorMessage variable. Thanks, Avi -- setup.php-- // load Smarty library require_once('smarty/Smarty.class.php'); require_once('DB.php'); class Smarty_test extends Smarty { var $db; function Smarty_test() { // Class Constructor. These automatically get set with each new instance. $this->Smarty(); $this->template_dir = '/srv/www/smarty_templates/'; $this->compile_dir = '/srv/www/smarty_templates_c/'; $this->config_dir = '/srv/www/smarty_configs/'; $this->cache_dir = '/srv/www/smarty_cache/'; $this->caching = true; $this->debugging = true; $this->assign('app_name','Test'); $this->$db = DB::connect("pgsql://user:password@server/database"); if (DB::iserror($this->$db)) { die($this->$db->getMessage()); } } } -- test.php require('/srv/www/smarty_includes/setup.php'); $smarty = new smarty_test(); if (isset($_POST['step']) && ('step1' == $_POST['step'])) { process_form(); } $smarty->display(test.tpl'); function process_form() { global $smarty; $field1 = trim($_POST['field1]); $field2 = trim($_POST['field2']); if (strlen($field1) == 0 || strlen($field2) == 0) { $smarty->assign('errorMessage', 'Both fields are required.'); return; } } -- test.tpl <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Test</title> </head> <body> X{$errorMessage}X </body> </html> -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

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