2010-06-03 60 views
0

我是一个Drupal新手量[计]预定义变量...的Drupal 6:自定义类型的项目

我研究,但couldnot发现:/没有任何预先定义的变量,让我CCK字段值计数?例如

;我有field_logo_sponsor,我需要显示所有徽标项目。现在我有5项

<?php print $node->field_logo_sponsor[0]['view'] ?> 
<?php print $node->field_logo_sponsor[1]['view'] ?> 
<?php print $node->field_logo_sponsor[2]['view'] ?> 
<?php print $node->field_logo_sponsor[3]['view'] ?> 
<?php print $node->field_logo_sponsor[4]['view'] ?> 

道理,那些使用它的方式:/如果对于任何计数变量,我只是将创建一个循环为,并在显示他们或while循环

鉴赏帮助!非常感谢!

回答

2

如何:

<?php 
foreach($node->field_logo_sponsor as $logo_sponsor) { 
    print $logo_sponsor['view']; 
} 
?> 

而且count($node->field_logo_sponsor)应该回到你的项目数。

+0

工作很棒!谢谢! :)愚蠢的我,我怎么也想不起来! :) – 2010-06-03 18:10:46

0

旁注:从来没有使用

foreach($node->field_logo_sponsor as $logo_sponsor) { 
    print $logo_sponsor['value']; 
} 

即使是calue包含你想要什么,并且视图不包含你想要的HTML。价值是非转化的,也就是说,它可以(并且因此将在某个时刻)包含像XSS这样的东西。

相关问题