The View Calendar module produces a block with the calendar legend in, that has a configurable option for which calendar view the legend should refer to. On the site I am working on, I have two different needs for the Views Calendar - one as a public calendar and one as a shift calendar with different legends required for each.

I have looked at http://drupal.org/node/399634 but can't seem to work out how this applies to the calendar.module code extracted below relating to the legend block.

I have a fairly basic knowledge of PHP, but this has flummoxed me. Additionally, I cannot find where the block delta is referenced. In other blocks it appears in the 'Configure block' link as a number, but in this one, it appears as a friendly URL.

/**
 * Implementation of hook_block_configure().
 */
function calendar_block_configure($delta = '') {
  switch ($delta) {
    case 'calendar_legend':
    $options = calendar_list_views();
    $form['calendar_legend_view'] = array(
      '#type' => 'select',
      '#title' => t('Legend View'),
      '#description' => t('Choose the view display that contains the settings for the stripes that should be displayed in a legend in this block. Note that if you change the stripe values in that view you will need to clear the cache to pick up the new values in this block.'),
      '#default_value' => variable_get('calendar_legend_view_' . $delta, ''),
      '#options' => $options,
    );
    return $form;
  }
}

/**
 * Implementation of hook_block_save().
 */
function calendar_block_save($delta, $edit = array()) {
  if ($delta == 'calendar_legend') {
    variable_set('calendar_legend_view_' . $delta, $edit['calendar_legend_view']);
    drupal_set_message(t('The view for the calendar legend has been set.'));
  }
}

/**
 *  Implementation of hook_block_view().
 */
function calendar_block_view($delta = '') {
  switch ($delta) {
    case 'calendar_legend':
      // Create the content before returning the block
      // so empty content won't still create the block.
      $view = variable_get('calendar_legend_view_' . $delta, '');
      $content = theme('calendar_stripe_legend', array('view' => $view));
      $block['subject'] = t('Calendar Legend');
      $block['content'] = $content;
      return $block;
  }
}

Any advice or tips would be much appreciated.

Comments

intrafusion’s picture

Status: Active » Closed (works as designed)

The link you have referenced is for D6 which is probably why you're having trouble.

Please look at the README.txt in the module folder for some help

yorkshire-pudding’s picture

Thank you for your response.