The sections form item weight is hard coded in the hook_form_alter().
Better way Implementation of hook_content_extra_fields()

Comments

sweetchuck’s picture

StatusFileSize
new1.9 KB

This is a simple solution.

hass’s picture

Status: Active » Postponed (maintainer needs more info)

There is no hook_content_extra_fields in core?

sweetchuck’s picture

The weight of the theme selector fieldset (which is added in the sections_form_alter() in line 90) is hard coded to 30.
The site administrators cannot change the position of this filedset on the form.
Apply this patch and goto ?q=admin/content/node-type/story/fields page, when CCK is installed and you will see what is the different.
hook_content_extra_fields() called by the CCK module.

hass’s picture

And without cck?

sweetchuck’s picture

Drupal without CCK is like Dallas without Boby Ewing. :-)

Add a module_exists check.

function sections_form_alter(&$form, $form_state, $form_id) {
  // Add theme selection option to node forms.
  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
    $node = $form['#node'];
    $form['sections'] = array(
      '#type' => 'fieldset',
      '#title' => t('Theme configuration'),
      '#collapsible' => TRUE,
      '#collapsed' => !$node->sections['theme'],
      '#tree' => TRUE,
      '#description' => t('This setting allows you to create a section per node. A node section will get the highest weight and take precedence about all other inheriting sections.'),
      '#access' => user_access('assign node theme'),
    );
    $form['sections']['theme'] = array(
      '#type' => 'select',
      '#title' => t('Select theme'),
      '#default_value' => $node->sections['theme'],
      '#options' => _sections_theme_select(),
      '#description' => t('Select the theme you want to use for this node. Disabled themes are not used until they are enabled on <a href="@url">themes</a> page.', array('@url' => url('admin/build/themes')))
    );
    
    if (!module_exists('content')) {
      $form['sections']['#weight'] = 50;
    }
  }

  // Disable core Administration theme.
  if ($form_id == 'system_admin_theme_settings') {
    // TODO: If other modules like theme_settings add form items, these items are not disabled.
    $form['admin_theme']['#disabled'] = TRUE;
    $form['node_admin_theme']['#disabled'] = TRUE;
    drupal_set_message(t('The configuration options have been disabled for compatibility reasons with the sections module. Configure the administration theme via <a href="@sections-admin">sections</a>.', array('@sections-admin' => url('admin/build/sections'))), 'warning', FALSE);
  }
}
hass’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)
sweetchuck’s picture

Status: Closed (works as designed) » Needs review
StatusFileSize
new2.33 KB
hass’s picture

Status: Needs review » Closed (won't fix)

I do not see the reason why we need to change this. No module I'm aware about - does this. All core modules assign a weight of 30, path_redirect and many others, too. I have never ever seen a module that works your way. Therefore won't fix.

sweetchuck’s picture

This implementation explain each fields of core modules for the Manage Fields page.
http://drupalcontrib.org/api/function/content_content_extra_fields/6

and here are some other modules
http://drupalcontrib.org/api/search/6/_content_extra_fields

sweetchuck’s picture

Status: Closed (won't fix) » Needs review
hass’s picture

I was unclear... I do not care much about cck here. Other modules work thecurrent way, too. I see no reason why we must change this as it is very uncommon.