This is a follow-up to #910510: Add support for event class / assigning colors to events
This is a feature that I really, really like about the Calendar module. It's currently possible to set class names for particular taxonomy terms attached to node events using a theme function, but I think 90% of this module's users will not have the know-how to do that.
It would be great if we had some sort of little UI widget, either on the FullCalendar settings page, or (preferred, since we could have classes per-view) in the FullCalendar settings for each FullCalendar-enabled view display.
The widget would need to first allow the user to choose a taxonomy to be used to assign colors, then have a color selection widget for each taxonomy term in that vocabulary. Graphical color picking UI == major win.
Apparently the Crayon module is supposed to help with that—I haven't used it yet, so I can't speak to it one way or another.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 1041068-17-colors.patch | 537 bytes | geerlingguy |
| #15 | 1041068-15-colors-admin.patch | 1.97 KB | geerlingguy |
| #12 | calendar-settings.png | 15.33 KB | geerlingguy |
| #12 | calendar-content-types.png | 75.12 KB | geerlingguy |
| #12 | calendar-legend-vocabs.png | 19.88 KB | geerlingguy |
Comments
Comment #1
geerlingguy commentedAfter thinking about this a bit, and talking with timplunkett in IRC, it seems to me that we have two options:
1. Add this functionality, and the storage of colors-per-term-per-view to FullCalendar itself.
2. Create a new module (timplunkett suggests "fullcalendar_crayon.module"), and do the work there.
I'm leaning towards 2.
In this module, I would have the module implement a theme function that adds classes for each taxonomy term in a given taxonomy to fullcalendar. The module would also have a settings page where the user would be able to choose a color for each term in a given taxonomy (or all the taxonomies, if the user wants!).
Then, the module would use drupal_add_css() to add a generated CSS file (could check out the Code per Node module for implementation samples for that) to the site, which themes FullCalendar to add the color definitions for all the classes...
For now, I'm going to keep working in this issue... but if I get time to work on the module, I might post it to it's own project page and continue development there.
Comment #2
tim.plunkettIncluding it as a submodule would be highly preferable to a separate module. If it really takes off, I can give you commit access to work on the submodule.
Features are going into 2.x.
Comment #3
geerlingguy commentedSounds good - I will work on this as a submodule and submit patches here. Though, I might work on it in D6 first, until I get a firmer grasp on D7/views, which has changed a bit. I have the books, and the bookmarks, but so far I've only done simple D7 work (mostly theming).
Comment #4
dafederThis would be awesome. I would be up for helping with d6.
Comment #5
gmak commentedCan I suggest you also look at the option of colouring based on Organic Groups? I know that I, like a lot of others, are using this in the current Calendar module, but would love to see it in FullCalendar.
Comment #6
aspilicious commentedSubscribe, if I have some D6 code I can help porting to D7...
Comment #7
FrequenceBanane commentedsubscribe
Comment #8
tim.plunkettCalendar supports color picking for:
Content types
Taxonomy vocabularies
Taxonomy terms
Organic groups
All the magic happens in calendar/includes/calendar_plugin_display_page.inc and js/calendar_colorpicker.js
We JUST got rid of our FullCalendar display plugin because we weren't using it, but we might have to add it back, and people will have to use it if they want colors, or possibly Google calendars...
Comment #9
tim.plunkettAlright, I added back fullcalendar_plugin_display_page.inc, so we can use it similarly to calendar module.
Comment #10
geerlingguy commentedAn additional option could be to set colors for taxonomies, Groups, content types, etc. universally, on a sub-page of the FullCalendar admin page. In some sense, that makes more sense than setting colors per-view, especially if your site's going to have tons of different calendars (like some of mine).
However, if you're only going to have one calendar on a site (most cases), then it makes sense to use the views plugin.
Comment #11
geerlingguy commentedMockup of fullcalendar color settings admin page attached - For content types and OG, this would be sufficient. But I worry about taxonomies - we can't just load in all vocabs/terms by default and allow coloring per term, because some sites could have thousands (or more) of terms in certain freetagging vocabs...
Comment #12
geerlingguy commentedFor reference, Calendar.module approaches the problem completely through the views interface, by adding a "Calendar Settings" section to the calendar view, and in that section, there are a number of different sections for setting colors for content types, terms, groups, etc., and the interface can be a bit cumbersome. But, it gets the job done appreciably well.
See attachments for some screengrabs from a view on one of my sites.
One of the gotchas I've encountered is that (a) you can't assign colors based on more than one vocabulary per view, and (b) the whole 'select a vocabulary in one settings pane, then set colors in another settings pain' thing is kind of annoying. It's a little easier to set colors for groups/content types.
Comment #13
tim.plunkettThe Calendar module provides a colorpicker for each possible content type, since it can't know which nodes it will return.
But with entities and views relationships, you could theoretically place every entity type on the same calendar. Files, users, taxonomy terms, taxonomy vocabularies, comments for each node type, each node type, and any custom entities. That's a LOT of possibilities. Any idea on how to manage them all? Fieldset per entity-type?
Comment #14
geerlingguy commentedI think that may be the only way to do it, if we do thing the same way as calendar.module. An alternative is to implement only Taxonomy-based colors first, then maybe Organic Groups, then etc... If we make it pluggable, we could make each entity type displayable (or not) with a separate module, or a checklist on the settings page.
That way, for someone like me, who only ever colors things based on taxo terms, I could just have the terms coloring show.
Comment #15
geerlingguy commentedMy rough start (half of the time was spent figuring out Git... however, the 'Git on Drupal.org' session was extremely helpful in this regard) is attached.
Basically, this patch adds a 'Colors' administration tab on the FullCalendar settings page. I'm going to try to come up with a good way to allow users to set colors per taxonomy, per node type, or per group... but I'm going to focus on taxonomies first, simply because I love and use taxonomy for colors everywhere :P
Comment #16
geerlingguy commentedAfter speaking a bit with timplunkett at DrupalCon, it looks like we're going to to with the separate module route. So, I'm going to work on a quick patch to create a MENU_DEFAULT_LOCAL_TASK for the current FullCalendar admin page, and in the contrib addon module, I'll add a 'Colors' menu tab to the FullCalendar admin page.
Comment #17
geerlingguy commentedHere's a patch for fullcalendar.module that sets the default local task, and adds a weight (so I can put the Colors tab to the right of the default/FullCalendar tab).
Comment #18
tim.plunkettMENU_NORMAL_ITEM is the default, so no need to add that.
Otherwise, do you want this to go in as is? I'd suggest using a sandbox for fullcalendar_color, and then I can merge it in. Better than swapping patches.
Speaking of patches, if you use the workflow laid out on the Git Instructions tab, then you'll get credit as the author.
Comment #19
geerlingguy commented@tim.plunkett - yes, the rest of the patch should go in as-is. Didn't have time to work on it too much on the trip to Rome, but I'll have some time (a lot of time, actually) by next Sunday. Might at least have a working sandbox with at least Taxonomy accounted for.
One thing I'm trying to decide right now is what kind of colorpicker library to use. The front runner in my mind is Colorwheel, a jQuery plugin that has a nice array of options, and works well in different sizes. I don't know if using Farbtastic (which Calendar.module uses) is as simple/easy for our purposes... though it is updated from the older version by Steven Wittens.
Comment #20
tim.plunkettThere is a farbtastic in core, which is a major plus.
I'll commit this patch later tonight.
Comment #21
geerlingguy commentedTrue, didn't think about that...
Comment #22
geerlingguy commentedSandbox module set up: http://drupal.org/sandbox/geerlingguy/1102994
I'm going to try to work on this here and there in the next week or so, but it seems things are stacking up every evening this week! The one weak area where I'm going to have some trouble, and could use some help, is farbtastic integration. I'm no JS expert, and I've so far avoided ever doing much Drupal JS to this point :-/
If someone would like to help with that area, I'm definitely open to that :-)
Comment #23
tim.plunkettCommitted the patch from #17.
http://drupalcode.org/project/fullcalendar.git/commit/9749749
Comment #24
aspilicious commentedAnd we got some first results :) we *only* need to link our chosen colors with a css file.
http://drupal.org/node/1130092
Comment #25
geerlingguy commented#1130092: Fixed farbtastic stuff was committed. I'm going to hop back in there in the next week or two and try to finish that last bit up... might need to request a tweak or two to fullcalendar.module, but I'm not sure yet (I've only thought it through in my head a little).
Also, noticed #1130190: No way to get to Colors Admin through UI - this is the result of my having checked out the last stable release (2.0-alpha3). Maybe we can get an alpha-4 or beta-1 out by the time FC-Colors is ready? :-)
Comment #26
aspilicious commentedSrry geerlingguy to steal all the fun but I made some progress tonight:
http://drupal.org/node/1130196
Comment #27
geerlingguy commentedNo problem at all! You'll probably have it all finished and working by the time I get to spend another minute on it :P
I was wondering, the line in the .info file:
Seems to break my Drupal 7.0 install... is this something new included in 7.x dev? I had to remove the "= fullcalendardependencies[] " part to get the module to be enable-able on my install.
Comment #28
aspilicious commentedI can't find that line that gives you some troubles?
Comment #29
geerlingguy commentedThat line should be in the current (master) branch of fullcalendar_colors, in the .info file, last line. At least, it's that way when I do a new checkout.
Comment #30
aspilicious commentedI have different results, I only have
Comment #31
geerlingguy commentedHmm... me too now. That was odd. I just refreshed the repo, and it's normal again.
Comment #32
geerlingguy commentedFullCalendar Colors module is now included in the latest alpha release of FullCalendar 7.x-2.x: http://drupal.org/node/1136114
Great work, everyone!
Comment #33
tim.plunkettOh goddamn it I meant to reference this in the commit message. Oh well!
Comment #34
geerlingguy commentedIt's late... you have an excuse :-)
Comment #35
BenK commentedSweet.... thanks for this!
Comment #36
aspilicious commentedThis is great news :)