Jump to content

Smarty won't assign section values


Anzeo

Recommended Posts

Hi all,

 

 

 

I've recently switched from TemplatePower to Smarty and it was definitely the right choice. I'm fiddling around a bit with all the possibilities and stumbled upon a strange porblem, which I seem not to be able to fix.

 

I want to use a simple section, my template code is:

{section name=row loop=$MYPOEF}
{strip}
$MYPOEF[row].ID
$MYPOEF[row].Username<br />
{/strip}
{/section}

 

and in my php file I have:

 $qry = new SelectQuery("SELECT ID,Username FROM USER", TRUE );
$tpl->assign("MYPOEF",$qry->result());

 

the $qry->result returns an associative array (var_dump below):

array(3) { 
[0]=>  array(2) { ["ID"]=>  string(1) "1" ["Username"]=>  string(4) "test" }
[1]=>  array(2) { ["ID"]=>  string(1) "2" ["Username"]=>  string(5) "test1" }
[2]=>  array(2) { ["ID"]=>  string(1) "3" ["Username"]=>  string(5) "test2" }
} 

 

Which seems correct to me? Yet the output is:

$MYPOEF[row].ID $MYPOEF[row].Username
$MYPOEF[row].ID $MYPOEF[row].Username
$MYPOEF[row].ID $MYPOEF[row].Username 

 

I've tried searching for tutorials, looked into the manual over and over but I can't seem to figure out what's wrong with this? (other variables on the pages are assigned correctly and I have setup the $tpl object correctly as a smarty one).

 

Does anyone see what I'm doing wrong here? Any help greatly appreciated.

 

 

 

Thanks in advance,

A.

Link to comment
https://forums.phpfreaks.com/topic/182389-smarty-wont-assign-section-values/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.