Menu Settings per Content Type with Domain Access
wiredloose - September 17, 2009 - 11:36
| Project: | Menu Settings per Content Type |
| Version: | 6.x-1.0 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
| Issue tags: | CTM, domain access |
Description
I work with a site that use the Domain Access (DA) module. I love your
module, and I have written a module so that it works with DA (I haven't put
it up yet).
However, it will only work correctly with a small change to the code for
CTM:
// Menu Settings for Node Edit (Form)
elseif (isset($form['#node']) && $form['#node']->type .'_node_form' ==
$form_id) {
$menu_settings = variable_get($form['#node']->type.'_menu_settings',
array());
//THIS IS THE EXTRA LINE - ISN'T IT ANYWAY A GOOD IDEA TO FILTER BEFORE
THE ARRAY_INTERSECT() BELOW?
$menu_settings = array_filter($menu_settings);
if ($menu_settings) {
$menus = array_intersect_key(menu_get_menus(), $menu_settings);
$options = menu_parent_options($menus, $form['menu']['#item']);
$form['menu']['parent']['#options'] = $options;
} else {
unset($form['menu']);
}
}Below is my code for a Domain CTM-module:
/**
* @file
* Multi domain support for Menu Settings per Content Type (CTM).
*/
/**
* implementation of hook_domainconf()
*
*/
function ctm_domainconf($domain) {
$node_types = node_get_types('names');
$options = menu_get_menus();
$form['ctm_conf'] = array(
'#type' => 'fieldset',
'#title' => t('Menu Settings per Content Type (CTM) settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 10
);
foreach ($node_types as $key => $value) {
$default_values = variable_get($key.'_menu_settings', array());
$form['ctm_conf'][$key.'_menu_settings'] = array(
'#type' => 'checkboxes',
'#title' => t('Menu settings for <strong>'. $key.'</strong>'),
'#options' => $options,
'#default_value' => $default_values,
);
}
return $form;
}If you'll consider the change to the code, I could use the module straight
from the source without any modifications - AND I will be able to upgrade your
module without any problem, in case you make future versions.

#1
+1
PS. mind sharing that module....
#2
Alright got it installed, here's the module (credits to wiredloose)
Working great, thanx.
+1 for line of code to be implemented...
Cheers