Place the blocks contents in a noscript tag so if the user doesn't have js enabled they at least get an old version of the block.

CommentFileSizeAuthor
#1 ajaxify_regions-802698.patch5.1 KBmikeytown2

Comments

mikeytown2’s picture

Status: Active » Needs review
StatusFileSize
new5.1 KB

Works for me, let me know what you think.

csevb10’s picture

My concern about this is how it would work for all use cases. For some of the things we've looked at previously, it would work like a charm (aka content that would simply be stale if not served dynamically), but there are a set of use cases where it would serve either wrong or bad content that I'm concerned about (and what the module was really intended to help with):
1. user-specific data (user information, user-specific links, etc)
2. role-specific or inaccessible content (i.e. content that only certain people should see or only that user should have access to, etc)

Let me know if that makes sense. It might make sense to actually come up with some way to make that determination on a per-block basis, so I'll start brainstorming ways to resolve the issue.

Btw, I'll clean up all the whitespace issues so the patches are easier to review. :-P

mikeytown2’s picture

I'm using this with the boost module, so I do not have to worry about user/role specific data. In terms of per block configuration we could copy what the domain_blocks module does with hook_form_alter()

/**
 * Implementation of block form_alter().
 */
function domain_blocks_form_alter(&$form, $form_state, $form_id) {
  if (($form_id == 'block_admin_configure' || $form_id == 'block_box_form' || $form_id == 'block_add_block_form')) {
    // If the user is a site admin, show the form, otherwise pass it silently.
    if (user_access('set domain access')) {
      $module = $form['module']['#value'];
      $delta = $form['delta']['#value'];
      $form['domain_vis_settings'] = array(
        '#type' => 'fieldset',
        '#title' => t('Domain specific visibility settings'),
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
        '#weight' => 0,
      );
      $previous_block_domains = _domain_blocks_load($module, $delta);
      $block_domains = array();
      if (count($previous_block_domains) > 0) {
        foreach ($previous_block_domains as $value) {
          $value == 0 ? $value = -1 : $value = $value;
          $block_domains[] = $value;
        }
      }
      $options = array();
      foreach (domain_domains() as $data) {
        // Cannot pass zero in checkboxes.
        ($data['domain_id'] == 0) ? $key = -1 : $key = $data['domain_id'];
        // The domain must be valid or accessible for the current user
        if ($data['valid'] || user_access('administer domains') || user_access('access inactive domains')) {
          $options[$key] = $data['sitename'];
        }
      }
      $form['domain_vis_settings']['domain_blocks'] = array(
        '#type' => 'checkboxes',
        '#title' => t('Display on'),
        '#options' => $options,
        '#required' => FALSE,
        '#description' => t('Limit block display to these affiliates. This block is visible on all domains by default using this theme.'),
        '#default_value' => $block_domains,
      );
      $form['domain_vis_settings']['previous_domain_blocks'] = array(
        '#type' => 'value',
        '#value' => $previous_block_domains,
      );
      $form['#submit'][] = 'domain_blocks_form_submit';
    }
  }
  // Submit handler for user defined block deletion
  if ($form_id == 'block_box_delete') {
    $form['#submit'][] = 'domain_blocks_delete_submit';
  }
  // Blocks overview form submit
  if ($form_id == 'block_admin_display_form') {
    $form['#submit'][] = 'domain_blocks_admin_display_submit';
  }
}
mikeytown2’s picture

One more thing that might be good is to have a ajax timeout and if the timeout is reached then default to what's in the noscript tag.