In the FullCalendar Legend block configuration I can select the type of legend: Taxonomy or Bundle.

I would like my legend only to display specific vocabularies. The events on my calendar have multiple term reference fields (tags, venue, category) and I don't want all of them in the legend.

Vague ideas-

  • Not all of my vocabularies have Colors enabled: perhaps it would be a start to exclude the vocabulary from the legend if it doesn't have colours defined.
  • Allow selecting one or more vocabularies in the block configuration.
  • How about multiple blocks with a different configuration for each one? à la Menu Block
  • Or a Views area handler instead of a block? this might be neater: perhaps the configuration could be automatic based on the fields passed to the View. I don't know enough about area handlers yet.

I could do some work on this but not for a few weeks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Component: FullCalendar Colors » FullCalendar Legend

Added a new component, don't worry, it wasn't there when you filed the issue :)

Blocks are going to stay single-purpose, but once #1373422: Add documentation for FullCalendar Legend is done everyone will realize that Panels is awesome and you can use the custom pane FullCalendar Legend provides to do multiple things.

@pjcdawkins, which would be more useful? Choosing a field to restrict by, or a vocabulary? By field, I mean a taxonomy term reference field, to use its allowed vocabularies setting (we're already using that anyway).

pjcdawkins’s picture

Ah, I hadn't considered the pane!

Choosing a term reference field would make more sense than choosing a vocabulary.

mcpuddin’s picture

Another way to do this is to use template overrides to hardcode the ones you want to display:

function crystalline_preprocess_fullcalendar_legend(&$variables) {
  $element = array(
    '#attached' => array(
      'css' => array(
        ctools_attach_css('fullcalendar_legend.theme', 'fullcalendar_legend'),
      ),
    ),
  );
  foreach ($variables['types'] as $type_name => $type) {
    //do not allow anything but field_cal_cat be a legend type
    if($type['taxonomy_field'] != 'field_cal_cat') {
      continue;
    }

    $element[$type_name] = array(
      '#type' => 'container',
      '#attributes' => array(
        'class' => _fullcalendar_legend_get_classes($type),
        'entity_type' => $type['entity_type'],
        'bundle' => $type['bundle'],
        'field' => $type['field_name'],
      ),
    );
    // Sanitize the label.
    $type['label'] = check_plain($type['label']);
    if (isset($type['uri'])) {
      $element[$type_name]['type'] = array(
        '#type' => 'link',
        '#href' => $type['uri']['path'],
        '#title' => $type['label'],
      );
    }
    else {
      $element[$type_name]['type'] = array(
        '#markup' => $type['label'],
      );
    }
  }

  $variables['element'] = $element;
}
tkbcreative’s picture

For anyone still having this issue and not wanting to go down the Panels route there is another simple way to solve the Legend issue here at #10 http://drupal.org/node/1416536#comment-6832116

wickwood’s picture

If this can be done with Panels, could someone post some explicit instructions, or if they are posted point me to them?

What is posted in #1373422: Add documentation for FullCalendar Legend didn't help me at all solve this problem. That problem being to create a calendar that has cotent that has more than one taxonomy, but only one of those taxonomies should be in the legend.

Thanks for any help in advance!

Steve

kristiaanvandeneynde’s picture

It seems another developer came up with a solution on a project that we recently ordered. He failed to post it to drupal.org however.

It seems to work, so I decided to clean up his patch a bit and post it here. Feel free to try it out and further improve it.

kristiaanvandeneynde’s picture

Status: Active » Needs review
kristiaanvandeneynde’s picture

As I personally also needed the patch from #1880252-15: Allow to show/hide events by clicking on the legends, I solved the merge conflict between that issue and this one. Attached is a patch that is basically a reroll, should the other issue get committed first.

If you want to close and commit this issue before that one, you still need to use the patch from #6.

kkasischke’s picture

I applied the patch from #1880252-15: Allow to show/hide events by clicking on the legends, and then the patch from this issue, #8. Now, no matter which term I click in the legend, all the events toggle between hidden/shown, instead of just the ones with the appropriate terms. Has anyone else observed this? Not sure where to go from here. Will cross-post this in #1880252: Allow to show/hide events by clicking on the legends