Fix for looping through CCK Matrix to provide a view for each field

  1.   foreach (array(1,2,3,4) as $matrixrow) {
  2.     foreach (array(1,2) as $matrixcol) {
  3.       $matrixindex = $matrixrow.'_'.$matrixcol;
  4.       $table = array(
  5.         'name' => 'node_field_matrix_data',
  6.         'provider' => 'internal',
  7.         'join' => array(
  8.           'left' => array(
  9.             'table' => 'node',
  10.             'field' => 'nid'
  11.           ),
  12.           'right' => array(
  13.             'field' => 'nid'
  14.           ),      
  15.           'extra' => array(
  16.             'row' => $matrixrow,
  17.             'col' => $matrixcol
  18.           ),
  19.         ),
  20.         'fields' => array(
  21.           'value' => array(
  22.             'name' => t("Sitehelper: Meter $matrixindex"),
  23.             'sortable' => false,
  24.             'help' => t("This will show the value of meter $matrixindex."),
  25.           ),
  26.         ),
  27.       );
  28.       $tables["node_field_matrix_data_$matrixindex"] = $table;
  29.     }
  30.   }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.