smarty 获取数据的方法给点提示

#1 ryk007

Array
(
[0] => Array
(
[commts] => Array
(
[id] => 2
[demaId] => 645
[userID] => b94cd35fccce44d38c37073982587e22
[content] => 评论内容阿斯打死大赛的阿斯打
[createTime] => 2010-12-16 16:33:06
[uinfo] => Array
(
[userID] => b94cd35fccce44d38c37073982587e22
[nickName] => 七喜
[avatarPic] => resource/hostImg/2010.10/20101021203122956709.jpg
)
)
[repl] => Array
(
[0] => Array
(
[id] => 3
[demaId] => 645
[userID] => b94cd35fccce44d38c37073982587e22
[content] => 阿斯打死大赛的阿斯打阿斯顿撒旦
[createTime] => 2010-12-16 16:33:15
[uinfo] => Array
(
[userID] => b94cd35fccce44d38c37073982587e22
[nickName] => 七喜
[avatarPic] => resource/hostImg/2010.10/20101021203122956709.jpg
[motto] => 笔直是我的生活,弯曲才是我的生命
)
)
)
)

[1] => Array
(
[commts] => Array
(
[id] => 1
[demaId] => 645
[userID] => b94cd35fccce44d38c37073982587e22
[content] => 评论内容asdasdasdasdsadsadsa
[createTime] => 2010-12-16 16:01:05
[uinfo] => Array
(
[userID] => b94cd35fccce44d38c37073982587e22
[nickName] => 七喜
[avatarPic] => resource/hostImg/2010.10/20101021203122956709.jpg
)
)
[repl] =>
)
)


我查询出来的数据dump以后是上面的数据,
我现在想在html页面里面使用smarty 来获取数据
<{foreach item=dc from=$commlist}>
<{$dc.commts.uinfo.nickName}>
<{/foreach}>
红色部分我输出不到“七喜”
[uinfo] => Array
(
[userID] => b94cd35fccce44d38c37073982587e22
[nickName] => 七喜
[avatarPic] => resource/hostImg/2010.10/20101021203122956709.jpg
[motto] => 笔直是我的生活,弯曲才是我的生命
)
这里面的名字

顺便指点一下怎么获取下面[repl] 里面的数据~

2010-12-16 17:18:27

#2 jake

楼主用的foreach循环应该没错,而获取nickName的方法的确是如此。
你可以检查一下<{$dc}> <{$dc.commts}>它们的值是不是Array,那么就知道是否有数据到位了。
另外,可以通过配置 view -> debugging = true来开启smarty本身的调试。

2010-12-16 18:42:27