这就是我的内容类型image的样子 这个主题的最佳方式是什么?之前我使用了views和views-field-collections-items。但我根本无法获得第3个字段集合值,即收入信息。
建议以最佳方式主题此内容类型!
答案 0 :(得分:0)
我建议使用模板,根据需要更容易设计样式。以下是您的特定情况的示例:
<?php
$field_nation = field_get_items('node', $node, 'field_nation');
foreach ($field_nation as $nation) {
$fc = field_collection_field_get_entity($nation);
// Nation name
$field_nation_name = field_get_items('field_collection_item', $fc, 'field_nation_name');
$field_nation_name = $field_nation_name ? $field_nation_name[0]['value'] : '';
// Another nested field collection
$field_companies_info = field_get_items('field_collection_item', $fc, 'field_companies_info');
foreach ($field_companies_info as $company) {
$fc2 = field_collection_field_get_entity($company);
// Company name inside second field collection
$field_company_name = field_get_items('field_collection_item', $fc2, 'field_company_name');
$field_company_name = $field_company_name ? $field_company_name[0]['value'] : '';
// Industry inside second field collection
$field_industry = field_get_items('field_collection_item', $fc2, 'field_industry');
$field_industry = $field_industry ? $field_industry[0]['value'] : '';
// Another nested field collection for Revenue information
$field_revounue_info = field_get_items('field_collection_item', $fc2, 'field_revounue_info');
// ..... And here another foreach similar to those above
}
}
?>