Color programs on Station schedule according to taxonomy

Events happening in the community are now at Drupal community events on www.drupal.org.
zoen's picture

Hi all,

I created a small Drupal 7 feature module for a client, to let them color the programs on the schedule according to category.

So far this is all it is:

  • A taxonomy vocab station_program_type with a text field field_color on the terms
  • Theme registry overrides, to use my modified versions of theme_station_schedule_hour() and theme_station_schedule item()
  • Modified theme function for theme_station_schedule_hour(): roughly doubles the height of the schedule grid. Maybe this part should be removed to make this more general and color-focused.
  • Modified theme function for theme_station_schedule_item(): grabs the taxo term for the program, gets the value from field_color on that taxo term, and outputs inline CSS to color the schedule item accordingly
  • Function to parse the input from field_color, make sure it has a # if it's a hex color, otherwise just check_plains whatever string they entered and outputs it into the inline CSS
  • A CSS file. This could perhaps be removed - it's specific to the client's request.

I saw a few people around the internet asking for a way to color the schedule by taxonomy, so I'm going to share the feature here. If anyone's interested in this as a solution, let's discuss ways to improve this and make it more generally useful. Possibilities:

  • validation on field_color to make sure the string is a valid web color such as "blue", "thistle" or "tomato"
  • a web color picker instead of a text field
  • the ability to choose which taxonomy vocabulary is used, rather than having to use this one. In this case, I guess I would have to package in some code to let the user choose a taxo vocab, and then add field_color to that vocab.
  • remove client-specific elements like the increased height and other CSS tweaks
  • code cleanup
AttachmentSize
station_colors.tar_.gz2.91 KB

Radio

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: