If someone is wondering this, I made a hack. Based on move_FieldsToTab
Usage is simple. Create a rule mm_moveCategoryToTab and insert category ID (not name!)(required),new tad (required), roles (optional) and templates (optional).
The code gets tv:s in a category and moves them into new tab just like moveFieldsToTab does. Simple.
To get this to work you need to modify from the mm.inc.php section
// check if there are any name clashes between TVs and default field names? If there is, preserve the default field
if (!isset($mm_fields[ $n ])) {
$mm_fields[ $n ] = array('fieldtype'=>$t, 'fieldname'=>'tv'.$thisTv['id'].$fieldname_suffix, 'dbname'=>'', 'tv'=>true]);
}
$mm_fields[ 'tv'.$n ] = array('fieldtype'=>$t, 'fieldname'=>'tv'.$thisTv['id'].$fieldname_suffix, 'dbname'=>'', 'tv'=>true);
}
to
// check if there are any name clashes between TVs and default field names? If there is, preserve the default field
if (!isset($mm_fields[ $n ])) {
$mm_fields[ $n ] = array('fieldtype'=>$t, 'fieldname'=>'tv'.$thisTv['id'].$fieldname_suffix, 'dbname'=>'', 'tv'=>true, 'category'=>$thisTv['category']);
}
$mm_fields[ 'tv'.$n ] = array('fieldtype'=>$t, 'fieldname'=>'tv'.$thisTv['id'].$fieldname_suffix, 'dbname'=>'', 'tv'=>true, 'category'=>$thisTv['category']);
}
to get the needed information about categories.
The code itself
//---------------------------------------------------------------------------------
// mm_moveCatToTab
// Move all fields belonging to a category to a different tab
//---------------------------------------------------------------------------------
function mm_moveCategoryToTab($cat, $newtab, $roles='', $templates='') {
global $modx, $mm_fields;
$e = &$modx->Event;
$fields = '';
foreach ($mm_fields as $parent => $child) {
if ($child['category'] == $cat) {
$fields .= $parent.',';
}
}
$fields = trim($fields,",");
// if we've been supplied with a string, convert it into an array
$fields = makeArray($fields);
// if the current page is being edited by someone in the list of roles, and uses a template in the list of templates
if (useThisRule($roles, $templates)) {
$output = " // ----------- Move category to tab -------------- \n";
// If it's one of the default tabs, we need to get the capitalisation right
switch ($newtab) {
case 'general':
case 'settings':
case 'access':
case 'meta': // version 1.0.0 only, removed in 1.0.1
$newtab = ucfirst($newtab);
break;
}
// Make sure the new tab exists in the DOM
$output .= "if ( \$j('#tab".$newtab."').length > 0) { \n";
$output .= 'var ruleHtml = \'<tr style="height: 10px"><td colspan="2"><div class="split"></div></td></tr>\'; ';
// Go through each field that has been supplied
foreach ($fields as $field) {
// What type is this field?
if (isset($mm_fields[$field])) {
$fieldtype = $mm_fields[$field]['fieldtype'];
$fieldname = $mm_fields[$field]['fieldname'];
$output .= '
var toMove = $j("'.$fieldtype.'[name='.$fieldname.']").parents("tr"); // Identify the table row to move
toMove.next("tr").find("td[colspan=2]").parents("tr").remove(); // Get rid of line after, if there is one
var movedTV = toMove.appendTo("#tab'.$newtab.'>table:first"); // Move the table row
movedTV.after(ruleHtml); // Insert a rule after
movedTV.find("td[width]").attr("width",""); // Remove widths from label column
$j("[name^='.$fieldname.']:first").parents("td").removeAttr( "style" ); // This prevents an IE6/7 bug where the moved field would not be visible until you switched tabs
';
}
} // end foreach
$output .= "}";
$e->output($output . "\n");
} // end if
} // end function
I created a new file in the functions directory named categories.inc.php and added the above code to there.
Notes:
This suits my usage perfectly the way it is right now. YMMV. I use this with custom filter function (filters TV:s based on a value given in another TV).
edit: Trimmed the base code a bit