Drupal NAT-ng and Computed field don't befriend easily
All day tried to compute fields from child nodes assigned using NAT-ng. My logic doesn't seem to go so far. As far as I know I need to get content by using nid which is asigned to nat id by getting it I am capable to get term id and all nodes assigned to this term (also can fil开发者_运维百科ter content types)
ok got it all by myself. Don't know if it is the best way, but at least it is working :) ok here comes the code
<?php
$count = 0;
$results = db_query("SELECT {content_type_ski_station}.field_to_be_calculated FROM {nat_ng} LEFT JOIN {term_node} ON {nat_ng}.tid = {term_node}.tid LEFT JOIN {content_type_station} ON {term_node}.nid = {content_type_station}.nid WHERE {nat_ng}.nid=%d", $node->nid);
while ($result = db_fetch_array($results))
{
$return = $result;
$count += $return['field_to_be_calculated'];
}
$node_field[0]['value'] = $count;
?>
Now ir is using field from so called children nodes be happy :)
精彩评论