- コンテンツに労働者へのリンクが必要な会社
- 統計ノードにネクタイが付いているフットボール選手
私が直面しなければならなかったタスクは、このフィールドを表示する方法です。
- さまざまな材料で構成されたレシピ(チキン1個、オレンジ2個、スパイス50g)
デフォルトでは、CCK自体が複数または単一のノード参照選択をリストまたは対応するノードへのリンクとして作成します。 レシピを見つけるタスクは、レシピと材料がノードであることを前提としています。
したがって、Viewsを使用してコンテンツをレンダリングすると、次の結果が得られます。
ブルガリアチキン(レシピ)
- 鶏肉(材料)
- オレンジ(成分)
- スパイス(材料)
代わりに:
ブルガリアチキン(レシピ)
- 1鶏肉(材料)
- 2オレンジ(成分)
- 50gスパイス(材料)
残念ながら、GoogleとDrupal.orgでこの問題の解決策を見つけられなかったため、外に出なければなりませんでしたが、非常にシンプルで美しいことがわかりました。
Productノードに対して、別のTextマルチポールを追加します。これは、ノード参照の後にフィールドビューに配置します。
また、views-view-fields.tpl.phpテンプレート(または必要に応じて特定のビュー)に、マジックを記述します。
<?php
$nids = array();
?>
<?php foreach ($fields as $id => $field): ?>
<?php
if($id == 'field_product_nid') {
$nids = array_shift($field->handler->field_values);
continue;
}
if($id == 'field_product_title_value') {
$items = array();
$index = 0;
$titles = array_shift($field->handler->field_values);
foreach($titles as $title) {
$items[] = l($title['value'], 'node/' . $nids[$index++]['nid']);
}
// TODO: theming here
$field->content = theme('item_list', $items);
}
?>
<?php if (!empty($field->separator)): ?>
<?php print $field->separator; ?>
<?php endif; ?>
<<?php print $field->inline_html;?> class="views-field-<?php print $field->class; ?>">
<?php if ($field->label): ?>
<?php print $field->label; ?>:
<?php endif; ?>
<?php
// $field->element_type is either SPAN or DIV depending upon whether or not
// the field is a 'block' element type or 'inline' element type.
?>
<<?php print $field->element_type; ?> class="field-content"><?php print $field->content; ?></<?php print $field->element_type; ?>>
</<?php print $field->inline_html;?>>
<?php endforeach; ?>
これにより、タイトルフィールドのノード参照が置き換えられ、ビューがレンダリングされます。 この問題の解決策はありますか?