2013-08-06 89 views
1

在Smarty中迭代阵列时,我得到的结果与同一阵列的print_r()相冲突。通过Smarty在SugarCRM中迭代阵列

在阵列上做print_r()时,我可以看到数组中有2个对象,每个对象都是唯一的。但是,当我在阵列的每个项目上运行print_r()(通过foreach循环)时,我似乎得到了每个项目的相同结果。

任何人都可以识别我做错了什么吗?

请参阅下面的代码示例和结果。

代码:

{$fields.rgggo_spreadsheetcellmap_documents.value->beans|@print_r} 

输出继电器:

Array 
(
    [a852b076-a5cb-dda9-3868-52010d6957ab] => RGGGO_SpreadsheetCellMap Object 
     (
      [new_schema] => 1 
      [module_dir] => RGGGO_SpreadsheetCellMap 
      [object_name] => RGGGO_SpreadsheetCellMap 
      [table_name] => rgggo_spreadsheetcellmap 
      [importable] => 
      [id] => a852b076-a5cb-dda9-3868-52010d6957ab 
      [name] => 
      [date_entered] => 08/06/2013 09:52am 
      [date_modified] => 08/06/2013 02:16pm 
      [modified_user_id] => 1 
      [modified_by_name] => Sean 
      [created_by] => 1 
      [created_by_name] => Sean 
      [description] => Test 2 
      [deleted] => 0 
      [created_by_link] => 
      [modified_user_link] => 
      [team_id] => 2e201ae4-fac9-8426-44c5-4f54f5830831 
      [team_set_id] => 65bd59b2-b3ed-fb2b-6a85-4f8888229942 
      [team_count] => 
      [team_name] => Development 
      [team_link] => 
      [team_count_link] => 
      [teams] => 
      [assigned_user_id] => 
      [assigned_user_name] => 
      [assigned_user_link] => 
      [field] => document_type_text_c 
      [row] => 3 
      [col] => 1 

      .... a bunch more stuff here 
     ) 

    [f038918d-a13d-69f0-3541-51fff82f0497] => RGGGO_SpreadsheetCellMap Object 
     (
      [new_schema] => 1 
      [module_dir] => RGGGO_SpreadsheetCellMap 
      [object_name] => RGGGO_SpreadsheetCellMap 
      [table_name] => rgggo_spreadsheetcellmap 
      [importable] => 
      [id] => f038918d-a13d-69f0-3541-51fff82f0497 
      [name] => 
      [date_entered] => 08/05/2013 02:10pm 
      [date_modified] => 08/06/2013 02:17pm 
      [modified_user_id] => 1 
      [modified_by_name] => Sean 
      [created_by] => 1 
      [created_by_name] => Sean 
      [description] => 
      [deleted] => 0 
      [created_by_link] => 
      [modified_user_link] => 
      [team_id] => 2e201ae4-fac9-8426-44c5-4f54f5830831 
      [team_set_id] => 65bd59b2-b3ed-fb2b-6a85-4f8888229942 
      [team_count] => 
      [team_name] => Development 
      [team_link] => 
      [team_count_link] => 
      [teams] => 
      [assigned_user_id] => 
      [assigned_user_name] => 
      [assigned_user_link] => 
      [field] => description 
      [row] => 2 
      [col] => 1 

      .... a bunch more stuff here 
     ) 
) 

当我遍历数组...

{{foreach from=$fields.rgggo_spreadsheetcellmap_documents.value->beans key=k item=v}} 
    <pre> 
    {$v|@print_r} 
    </pre> 
{{/foreach}} 

我得到这些结果:

RGGGO_SpreadsheetCellMap Object 
(
    [new_schema] => 1 
    [module_dir] => RGGGO_SpreadsheetCellMap 
    [object_name] => RGGGO_SpreadsheetCellMap 
    [table_name] => rgggo_spreadsheetcellmap 
    [importable] => 
    [id] => f038918d-a13d-69f0-3541-51fff82f0497 
    [name] => 
    [date_entered] => 08/05/2013 02:10pm 
    [date_modified] => 08/06/2013 02:17pm 
    [modified_user_id] => 1 
    [modified_by_name] => Sean 
    [created_by] => 1 
    [created_by_name] => Sean 
    [description] => 
    [deleted] => 0 
    [created_by_link] => 
    [modified_user_link] => 
    [team_id] => 2e201ae4-fac9-8426-44c5-4f54f5830831 
    [team_set_id] => 65bd59b2-b3ed-fb2b-6a85-4f8888229942 
    [team_count] => 
    [team_name] => Development 
    [team_link] => 
    [team_count_link] => 
    [teams] => 
    [assigned_user_id] => 
    [assigned_user_name] => 
    [assigned_user_link] => 
    [field] => description 
    [row] => 2 
    [col] => 1 

    .... a bunch more stuff here 
) 

    RGGGO_SpreadsheetCellMap Object 
(
    [new_schema] => 1 
    [module_dir] => RGGGO_SpreadsheetCellMap 
    [object_name] => RGGGO_SpreadsheetCellMap 
    [table_name] => rgggo_spreadsheetcellmap 
    [importable] => 
    [id] => f038918d-a13d-69f0-3541-51fff82f0497 
    [name] => 
    [date_entered] => 08/05/2013 02:10pm 
    [date_modified] => 08/06/2013 02:17pm 
    [modified_user_id] => 1 
    [modified_by_name] => Sean 
    [created_by] => 1 
    [created_by_name] => Sean 
    [description] => 
    [deleted] => 0 
    [created_by_link] => 
    [modified_user_link] => 
    [team_id] => 2e201ae4-fac9-8426-44c5-4f54f5830831 
    [team_set_id] => 65bd59b2-b3ed-fb2b-6a85-4f8888229942 
    [team_count] => 
    [team_name] => Development 
    [team_link] => 
    [team_count_link] => 
    [teams] => 
    [assigned_user_id] => 
    [assigned_user_name] => 
    [assigned_user_link] => 
    [field] => description 
    [row] => 2 
    [col] => 1 

    .... a bunch more stuff here 
) 

回答