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:

$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.

Are you sure you have data in $rowdata?

Your use of section looks good to me. You've got those if statements. 
Sure they are all true. 

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




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to