• Download Gist
Script to replace CCK/Matrix headers with Product Node Reference
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
$thisNode = $element['#node'];
//Finding the Key the Product1 is in
$product1Key = 0;
foreach ($header as $key=>$item) {
if (preg_match('/.*Product1.*/',$item)) {
$product1Key = $key;
}
}
 
$j=1;
for ($i=$product1Key;$i<=$product1Key+4;$i++) {
$fieldProduct = 'field_product'.$j;
$theProduct = $thisNode->$fieldProduct;
$productId = $theProduct[0]['nid'];
$productName = $theProduct[0]['safe']['title'];
$header[$i] = '<a href="'.base_path().'node/'.$productId.'">'.$productName.'</a>';
$j++;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.