Is it possible to change the way the available "Publish To" domains list on the create and edit node pages?

A select box or some other way to compact the list when it reaches a certain number would be helpful. I don't know if it would help anyone else, with 100+ domain names like me.

Thanks for considering.

Comments

nonsie’s picture

There should already be another issue originally started from #367752: Domain Content: too many menu items that deals with the same problem but I cannot find it atm. 100+ domains is not that unusual.

agentrickard’s picture

Right now, you can implement this quickly with hook_form_alter(). We need ideas for the best way to generically handle this.

I don't think we ever started a new issue, so we can use this one. Simple first idea:

-- It would be easy to make the list configurable in the UI.

jeremyr’s picture

Configurable in the UI would be nice... if you meant that we could switch between the different ways for displaying them. An option to show the domains "collapsed by default" would be nice too.

I'm still very new at module development but would like to help where I can. Testing would be the thing I could do with out messing up anything.

mrgoltra’s picture

drop down please. subscribing

agentrickard’s picture

Status: Active » Needs review
StatusFileSize
new14.19 KB

Here's a patch that lets the site admin choose the format. The variable setting defaults to checkboxes, but switches to select list if more than 25 domains are present.

You can also force the format you prefer. This change applies globally to all form element in the core DA suite.

For developers, see the new domain_select_format() function and form elements like the options form in Domain Views > domain_views_access_plugin.inc.

  function options_form(&$form, &$form_state) {
    $domains = domain_domains();
    $options = array();
    $format = domain_select_format();
    foreach ($domains as $domain) {
      // Checkboxes cannot handles zeros.
      if ($domain['domain_id'] == 0) {
        $domain['domain_id'] = -1;
      }
      // The domain must be valid.
      if ($domain['valid'] || user_access('administer domains')) {
        // Filter checkboxes but not select lists.
        $options[$domain['domain_id']] = empty($format) ? check_plain($domain['sitename']) : $domain['sitename'];
      }
    }
    $form['domains'] = array(
      '#type' => empty($format) ? 'checkboxes' : 'select',
      '#multiple' => TRUE,
      '#options' => $options,
      '#title' => t('Domains'),
      '#default_value' => $this->options['domains'],
      '#description' => t('Only users with the selected permission flag will be able to access this display. Note that users with "access all views" can see any view, regardless of other permissions.'),
    );
    if ($format) {
      $form['domains']['#multiple'] = TRUE;
      $form['domains']['#size'] = count($options) > 10 ? 10 : count($options);
    }
  }
agentrickard’s picture

Status: Needs review » Patch (to be ported)
StatusFileSize
new14.3 KB

Updated patch. Committed.

agentrickard’s picture

Status: Patch (to be ported) » Closed (fixed)

D5 is dead.