Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8054 Posts in 1860 Topics- by 2099 Members - Latest Member: roi
Pages: [1] 2 3   Go Down
Print
Author Topic: Color coding Events  (Read 2552 times)
0 Members and 1 Guest are viewing this topic.
bwise
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« on: February 19, 2002, 04:16:00 PM »

I'm wanting a solution to color code events based on the user, and is scalable.
I have already implemented a solution, but as the calendars grow I'm finding this wasn't a scalable solution.
Here is what I did.
At the top of the template(default.html) I added this routine:

<%
sub myClass {
   my $author_id = $EVENT->{details}->{author_id};
   return $author_id;
}
%>
It's purpose is simply to return the author_id.

The routine is called everywhere events are generated.  I use a div tag in this context:

<DIV class="<%= &myClass %>">
# Events are generated from tags here, normally
</DIV>

 
Next, I added styles for each user(author_id).  So for example:

.medMeeting { background=#6699FF; }  

was added in the style sheet, and there is a user named "medMeeting."

This way each event will have a div tag around it and the class will correspond to the author_id.  The author_id is also in the style sheet, thus each event is color coded by the user.

Here is where it begins to spin out of control.  When we want to color code events, we must login as that user and ad the event.  This isn't too bad if there are only a couple of users.  However, this is no longer the case :-(

Not to mention that this is a headache, going in and modifying the style sheet each time a user is added is more maintence.  Let me point out, that when I say user, I'm thinking of it as an event category.  That category is what I'm wanting color coded.

So, what am I looking for?  I want a better solution that gives the functionality I'm looking for.  It scales well and is easy to maintain.

One solution I'm thinking about is...

Each calendar has one "super user".  This user can post to this calendar only.  
On the admin tool where you add an event.  Have a drop down menu that is generated dynamically listing the users for this calendar.  The user is selected (remember this is category type for color coding), enters the event as normal.  When they submit the event.  The event is automatically wrapped in font tag specifying a color(no style sheet needed).  Then it is stored in the events file.  So, when the event is next pulled it will display with color.  Problem here is, the text will be colored.  I'm sure I can work it out with a div tag that specifies style, so I get a colored block (yea good idea).
There are some other small items that need to be worked out like a list of colors, associating the user with a color in a config table, etc.

One thing I'd like to avoid here is modifying the script so much that future upgrades won't be applicable.

Disclaimer--
I'm thinking out loud here so if I've said something stupid it wasn't me.  ;-)

thanks for you input in advance,
Byron

Logged
Scott
Guest
« Reply #1 on: March 05, 2002, 07:23:00 AM »

Could you add a custom field with a list of colors, and use the value of that field to determine which CLASS the event should be? That way you wouldn't need to add the event as any specific user. The people entering the event could choose the color of the event (or its classification, which would then decide the color), and the admin could edit the event later if necessary to adjust the color.

------------------
Scott
CalendarScript.com


Logged
yullah
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #2 on: April 17, 2002, 09:08:00 PM »

using the default template, how would i set it up so that events in each of five categories come up as different colors? (in grid view) Would it be easier to edit each event individually and post a colored icon to label the event category? (i'm so not a programmer :-)
thanks!
info@yullah.com
Logged
TubaDave
New Member
*

Karma: 0
Offline Offline

Posts: 0

Student


WWW
« Reply #3 on: April 18, 2002, 05:49:00 PM »

Find <!-- GRID STYLE DISPLAY -->, then look down for the line that displays the title:

<A HREF="<%=$CGI_URL_QUERYSTRING%>view=Event&event_id=<%= EVENT FIELD(id) %>" CLASS="gridtext"><%= EVENT FIELD(title) %></A><BR>

Replace that with:

<%
if ($EVENT->{details}->{category} eq "cultural") {$color="#00FFFF";}
elsif ($EVENT->{details}->{category} eq "political") {$color="#0000FF";}
elsif ($EVENT->{details}->{category} eq "social") {$color="#00FF00";}
elsif ($EVENT->{details}->{category} eq "student") {$color="#FF0000";}
elsif ($EVENT->{details}->{category} eq "other") {$color="#FFFF00";}
else {$color="#FFFFFF";}
%>
<A HREF="<%=$CGI_URL_QUERYSTRING%>view=Event&event_id=<%= EVENT FIELD(id) %>" CLASS="gridtext"><FONT COLOR="<%=$color%>"><%= EVENT FIELD(title) %></FONT></A><BR>

You might also want to move that block of if's and elseif's up a few lines just after <%FOREACH EVENT%> so you can use <FONT COLOR="<%=$color%>"> around the time as well.

------------------
David Whittaker
http://www.uabcm.com/
http://www.csworkbench.com/

Logged

yullah
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #4 on: April 18, 2002, 07:09:00 PM »

TubaDave,
you are officially the BOMB :-)
thanks a bunch!!!
Logged
ben
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #5 on: May 31, 2002, 08:31:00 AM »

Hi TubaDave, I've tried your mod to color-code events which works great when adding new events, but I can't work out why it doesn't affect events that are already in the Calendar.

Any ideas??

Ben.

------------------

Logged
TubaDave
New Member
*

Karma: 0
Offline Offline

Posts: 0

Student


WWW
« Reply #6 on: May 31, 2002, 04:57:00 PM »

Events in the calendar don't have a category field yet.  When you add a field, it's blank in all the events that have already been added.  You'll have to edit each one of those events, and select an appropriate category (or whichever field you are keying off of for the color).

------------------
David Whittaker
http://www.uabcm.com/
http://www.csworkbench.com/

Logged

ben
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #7 on: June 01, 2002, 03:59:00 PM »

Well the thing is, I did add a category field first of all! I got a user to fill out a bunch of events, using the new category field, but when I add the mod to the script after the events have been added, the colours don't change :-(

I can't understand it, as I can click an event and I can see the entry for the category field is correct.

But, if I then add an event /after/ I modded the script, my new entry shows up the correct colour. The category field is a menu selection so I know it's not a spelling problem or something with the previously added events.

Does this make any sense?!

Ben

------------------

Logged
TubaDave
New Member
*

Karma: 0
Offline Offline

Posts: 0

Student


WWW
« Reply #8 on: June 01, 2002, 10:10:00 PM »

Then that is really wierd.  If you didn't change anything (it is case-sensitive...) between when the old events were added and the new ones other than that mod, then everything should either show the right color or not.  Can you edit the old events and just save them again and it work?

------------------
David Whittaker
http://www.uabcm.com/
http://www.csworkbench.com/

Logged

ben
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #9 on: June 10, 2002, 03:53:00 AM »

I've managed to make it work properly by starting again on a fresh template. Something must have got screwed up somewhere in the code (i.e. I messed it up!)

Sorry for wasting your time...... :-)


Ben.

------------------

Logged
ben
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #10 on: June 10, 2002, 04:13:00 AM »

Ah, it seems that I only see the problem when I apply the modification to the fydayspan template, but it works fine on the default template.
I cannot understand why that is?

Ben.

------------------

Logged
TubaDave
New Member
*

Karma: 0
Offline Offline

Posts: 0

Student


WWW
« Reply #11 on: June 10, 2002, 08:15:00 PM »

AHA!  The *dayspan* templates all have two different places where the <A HREF=...> tag appears (one for a normal display, and one for the dayspanning td's that appear below the actual date area.  It is quite possible that you modded the dayspan section, and not the normal area, which appears just above the dayspan area in the code.  Hope that helps.

------------------
David Whittaker

http://www.csworkbench.com/

Logged

ben
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #12 on: June 11, 2002, 03:50:00 AM »

TubaDave I bow down in your greatness!

Maybe I should have spotted that (hey I'm only learning :-)

Thanks for that,it works great now.


Ben.

------------------

Logged
Daniel
New Member
*

Karma: 0
Offline Offline

Posts: 0

Self Employed Webmaster


WWW
« Reply #13 on: November 25, 2002, 10:47:00 PM »

Hey there TubaDave,

Help Please...

What field is your mod looking at when it goes to change the colors. I must not have the correct field in my database, cause I'm not getting any colors.

Thanx.

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 235

Please don't PM me. Post in the open forum.


WWW
« Reply #14 on: November 26, 2002, 12:50:00 PM »

 
quote:
What field is your mod looking at when it goes to change the colors.

if ($EVENT->{details}->{category} eq "cultural") {$color="#00FFFF";}

It is looking at an Event field named "category".

Dan O.

------------------

Logged
Pages: [1] 2 3   Go Up
Print
Jump to: