RE: [PHP] Smarty template question

From: Date: Sun, 29 Sep 2002 00:46:43 +0000
Subject: RE: [PHP] Smarty template question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-118013@lists.php.net to get a copy of this message
> -----Original Message----- > From: Peter J. Schoenster [mailto:peter@schoenster.com] > Sent: Saturday, September 28, 2002 5:25 PM > To: php-general@lists.php.net > Cc: Matt Giddings > Subject: Re: [PHP] Smarty template question > > > > On 28 Sep 2002 at 15:48, Matt Giddings wrote: > > > Hello, > > > > Be for warned that I am new to smarty and for some reason I'm > > finding it very difficult to learn. ??? Anyway, my question is how do > > I access an array of associative arrays via the {section} statement? > > > > Heres the code: > > Matt, > > I suggest you break your code down to the simplest possible. Too many > factors in there for my taste. FWIW, I had to bang my head a few times > to get it and still have to verify my assumptions. For some reason I > took to Template::Toolkit rather fast but smarty is working fine for > me. > > Here are a few notes, but I'm fairly new to PHP so caution. > > First, totally unrelated to your question: > > > Function readComment( &$smarty, $bid ) { > > In Perl and in PHP I have my classes ONLY manipulate data and return > data to the handerl which then passes it off to what I call the > "viewer". In this way, in Perl for instance, I can use more than one > template system as I create a class for each template system and > manipulate the data as needed for that system. Works like a charm. In > this way you can use the code in your classes for manythings ... it's > not tied to your output. Also, now some might complain that this might > be slower or take more memory or whatever, but I do this with smarty: That does sound like a better and more logical approach. I think I'll incorporate that into my code. > $data =& $g->run($com,$fid); > > $data is an array of data returned by my functions. > $data['content'] = $g->viewer->Merge($data,$template); > > print $g->viewer->Merge($data,'index.html'); > > So I *wrap* the content of pages into a page which pulls in > header/footer rather than having a header/footer in every page. > > Okay, back to your qeustion: > > > > while( $row = $result->fetchRow( DB_FETCHMODE_ASSOC ) ) { > > $rowdata[$i] = $row; > > $i++; > > I don't think you need the $i. I need the $i because I'm assigning the every row from the result into an array. > Are you sure you have data in $rowdata? Yup, $rowdata is filled with data, and the right data at that. :) > Your use of section looks good to me. You've got those if statements. > Sure they are all true. This one might be my downfall, I'll have to dig into this one a bit more. > I'm using section in lots of stuff and it's working fine. > > When I run into trouble I work from the most basic, the simplest and > then move up. > > Peter --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.391 / Virus Database: 222 - Release Date: 9/19/2002

« previous php.general (#118013) next »