At the moment, it seems like the event module either chooses random colours from a set, or cycles through a set of colours for the stripe at the top of the event items on the calendar views.

I'm wondering if anyone has been able to make these stripes related to the node type?

I have four node types and I'd like to colour code the events in the calendar to relate to these.

Any suggestions?

Comments

nevets’s picture

In event.theme you will find functions like theme_event_node_week() with

  static $stripe, $stripe_map;

  if(!$stripe_map[$node->nid]) {
    if($stripe >= 10) {
      $stripe = 1;
    }
    else {
      $stripe++;
    }
    $stripe_map[$node->nid] = $stripe;
  }

  $output .= '<div class="event weekview">'."\n";
  $output .= '<div class="stripe-'. $stripe_map[$node->nid] .'"></div>'."\n";

Note there are several functions that do this based on what calendar view is being show.
What I did was take each of those functions and add them to my themes template.php file (if you do not have one you can create it.
You will need to change them so instead of starting with 'theme' they start with phptemplate (ex: theme_event_node_week becomes phptemplate_event_node_week)
Then replace the stripe code with something like

  $output .= '<div class="event weekview">'."\n";  // This code varies by theme function
  $output .= '<div class="stripe-'. $stripe_map[$node->nid] . '"></div>'."\n";

The key part is $stripe_map[$node->nid] becomes $stripe_map[$node->nid]. You will then need to provide the appropriate css rules to color and size the stripes.

gmak’s picture

I understand principle of what you're suggesting, but I'm not clear on how to check the node-type that is being used. Could you expand your explanation a bit more to include that part?

You say

The key part is $stripe_map[$node->nid] becomes $stripe_map[$node->nid].

But those are exactly the same. What should $stripe_map[$node->nid] actually become?

Please excuse my relative inexperience with the API and thanks for your help

nevets’s picture

That should have been: the key part is $stripe_map[$node->nid] becomes $node->type. You will then need to provide the appropriate css rules to color and size the stripes.

Axel_V’s picture

Any chance you can quickly elaborate on how this is supposed to look like in the style sheets? I've done the changes to my phptemplate. Now, lets say I've got a node type called short_events. How would the stripe color for this event type exactly be defined in the event.css?

I've tried something like this:

.event-calendar .event .stripe-content_short_events {
  height: 5px;
  background-color: #668CFF;
  width: 100%;
}

that doesn't work. I've tried other lines as well but I just can't get it working.
Any ideas?
cheers, xl

Axel_V’s picture

My problem had to do with some slight confusion about the changes in the output variable of the phptemplate function. To make it 100% clear, the line...

 $output .= '<div class="stripe-'. $stripe_map[$node->nid] . '"></div>'."\n";

...turns into...

 $output .= '<div class="stripe-'. $node->type.'"></div>'."\n";

Then you can go into the event.css and define your classes like this:

.stripe-content_short_event {
  height: 5px;
  background-color: #FF6;
  width: 100%;

content_short_event being my node type that I want to have with a stripe in a specific color.

xl

jiangxijay’s picture

Subscribe

scottrigby’s picture

I implemented your change -- But now I have 3 questions based on the results:

1. When I do this (I'm working in 5x), I see two drop down menus: "Select event terms to filter by" & "Select event type to filter by". This isn't all that meaningful to me, because I can either decide to add new content types per type of event, or to add categories for each type of event (and apply these different categories to the event content type). So would rather not show both. How do I hide one of these drop-down menus?

2. Also, now I see a link with the name of my custom event type - the alt text says "limit view to events of this type", which seems to be another way to filter the calendar. How do i hide this?

3. Ideally I'd like to change the color by category rather than by content type. Here's why: the problem with making custom content types just so we can color-code them on the calendar is if I want to change the type of event I'd have to re-make the content using another content type! Whereas categories can just be re-assigned without having to re-create the content. So my last question is - How would you change the color by category?

Thanks -

Scott Rigby
http://basekamp.com
http://PlausibleArtworlds.org

hillaryneaf’s picture

To hide "Select event terms to filter by" & "Select event type to filter by" go to Administer> Site configuration>Events>Event Overview.

There are two sections "Taxonomy filter controls" and "Content type filter controls". There's an option to "Never show" for both of them.

I'd also like to know how to change the color based on event category... (your #3)

Dominion’s picture

Unfortunately, It still does not work for me. Nothing has changed. Perhaps you are using another release?

Wartin’s picture

Finally I found a patch:

http://drupal.org/user/211194

It works well.

hillaryneaf’s picture

That's a link to a user.. not a patch.. or am I missing something? :\