Colorise eventtype in calendar?
chasz - December 26, 2008 - 01:31
| Project: | Event |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
Description
how can i colorise an event in the node and in the calendar?

#1
the cvalendar views provide the node type info in their classes you need to add appropriate CSS for them in event.css.
#2
run that by me again ?
Do you mean this?
http://drupal.org/node/67060/release
or something else?
#3
can u give an example??
say i have a event/taxonomy called Holidays and i would like them to show you with a red background, what do i need to do in the css?
#4
I can tell you what I've done with my Drupal 6 event calendar. I have a few different terms in my event taxonomy, and want each one to have a consistent colour. My taxonomy only allows one term per event, and they are numbered 1 to 5, which is important in this example.
The important part in the styling is the stripe CSS class. Events are themed using four different theme files depending on the view currently being themed:
Copy these into your theme folder so you can amend them without hacking the event module files. In Drupal 6 you'll probably need to empty your theme cache to pick up the new theme files.
Next step is to change the code in each template file which generates the stripe class from
<div class="stripe-<?php print $stripe ?>"></div>to
<div class="stripe-<?php print array_shift(array_keys($node->taxonomy)); ?>"></div>Now, events with taxonomy term 1 will get the class stripe-1, term 2 events will get the class stripe-2, etc. Clearly this will only work reliably if you only allow a single term per event!
If you wanted some more complex logic around the stripe class derivation (e.g. supporting multiple taxonomy terms per event) I'd suggest making a function in your template.php file to work this out. Change the template file stripe class generation to
<div class="stripe-<?php print foo_derive_stripe_class($node); ?>"></div>and in your template.php file create the function
function foo_derive_stripe_class($node) {
// apply rules based on node characteristics
$stripe_class = 1;
return $stripe_class;
}
(remembering to change foo to the name of your theme!)
If you want to override the presentation of each stripe class, you'll need to override the class styles from event.css. The current class definitions are along the lines of
.event-calendar .event .stripe-1 {background-color: #FF6;
height: 5px;
width: 100%;
}
You'll need to add more specificity to the selectors to make sure your new styles override the existing ones. e.g.
#content .event-calendar .event .stripe-1 {background-color: #FF6;
height: 5px;
width: 100%;
}
#5
This's what I was looking for. Thank you very much!