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


Login with username, password and session length

Search

 
Advanced search

8043 Posts in 1856 Topics- by 2099 Members - Latest Member: roi
Calendar Script CommunityCustomizationCustomizing CalendarScript (Moderators: scott, DanO, Marty)Colored cell background accordind to catagory (solved)
Pages: [1]   Go Down
Print
Author Topic: Colored cell background accordind to catagory (solved)  (Read 589 times)
0 Members and 1 Guest are viewing this topic.
Audiodox
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« on: March 10, 2004, 07:13:00 PM »

Score!  alright, after 9 hours of mucking around I come up with a solution to shaded cellbackgrounds according to catagory in the grid->today view, and I don't think it would be too dissimilar to change it in the rest of the views.

Look for this bit in default.html:

<%-- DAY VIEW --%>
<% } elsif ($VIEW eq "Day") { %>

<% if ($STYLE eq "Grid") { %>
<%-- GRID VIEW --%>

under it look for this:

<TD CLASS="thinborder" BGCOLOR="<%=$_GRID_CELL_BGCOLOR%>" VALIGN=TOP>

replace with this:

<%FOREACH EVENT%>
<% if ($EVENT->{details}->{category} eq "appointment") {
  $cellbg2="#4483D0";
} elsif ($EVENT->{details}->{category} eq "block") {
  $cellbg2="#1C406C";}%>
<%/FOREACH%>
<%IF NO EVENTS EXIST%>
<%{$cellbg2=$_GRID_CELL_BGCOLOR;}%>
<%/IF%>
<TD CLASS="thinborder" BGCOLOR="<%=$cellbg2%>" VALIGN=TOP>

*tear* I'm so happy! LoL!

Later,

-Ry : )

[This message has been edited by Audiodox (edited March 10, 2004).]

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

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


WWW
« Reply #1 on: March 10, 2004, 09:41:00 PM »

Congrats!...

but you mean you're pinting out:
<TD CLASS="thinborder" BGCOLOR="<%=some color here%>" VALIGN=TOP>
for each and every event listed inside a calendar grid? What about if multiple events are there?

Normally all events are printed inside a single grid (aka table cell). Where are you printing the closing table cell tags for each of those opening ones your code is causing to be printed?

Dan O.

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

Logged
Audiodox
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #2 on: March 10, 2004, 11:17:00 PM »

This is the full block:

<%FOREACH EVENT%>
<% if ($EVENT->{details}->{category} eq "appointment") {
$cellcolor2="#4483D0";
} elsif ($EVENT->{details}->{category} eq "block") {
$cellcolor2="#444444";}%>
<%/FOREACH%>
<%IF NO EVENTS EXIST%>
<%{$cellcolor2=$_GRID_CELL_BGCOLOR;}%>
<%/IF%>
<TD CLASS="thinborder" BGCOLOR="<%=$cellcolor2%>" VALIGN=TOP>

<SPAN CLASS="text">
<%FOREACH EVENT%>
<% if ($_SHOW_GRID_EVENT_BULLET) {%>•<%}%>
<% if ($_SHOW_EVENT_TIMES eq "ALL" | | $_SHOW_EVENT_TIMES eq "START") { %>
<% if ($EVENT->{'schedule'}->{'start_time'}) { %><%= SCHEDULE FIELD(start_time) %><% } %>
<% } %>
<% if ($_SHOW_EVENT_TIMES eq "ALL") { %>
<% if ($EVENT->{'schedule'}->{'end_time'}) { %>-<%= SCHEDULE FIELD(end_time) %><% } %>
<% } %>
<% if (($_SHOW_EVENT_TIMES eq "ALL" | | $_SHOW_EVENT_TIMES eq "START") && ($EVENT->{'schedule'}->{'start_time'})) { %> : <% } %>
<% if ($EVENT->{details}->{author_id} ne $User->{'Administrator'} ) { %>
<% if ($EVENT->{details}->{category} eq "appointment") {%>
Booked
<%} elsif ($EVENT->{details}->{category} eq "block") {%>
Unavailable
<%}%>
<% } elsif ($EVENT->{details}->{author_id} eq $User->{'Administrator'} ) { %>
<% if ($EVENT->{details}->{category} eq "appointment") {%>
<FONT SIZE="-2">[<A HREF="<%=$CGI_URL_QUERYSTRING%>view=Event&event_id=<%= EVENT FIELD(id) %>" STYLE="text-decoration:underline;">Appointment</A>]<BR></FONT>
<%} elsif ($EVENT->{details}->{category} eq "block") {%>
<FONT SIZE="-2">[<A HREF="<%=$CGI_URL_QUERYSTRING%>view=Event&event_id=<%= EVENT FIELD(id) %>" STYLE="text-decoration:underline;">Unavailable</A>]<BR></FONT>
<%}%>
<% } %>
<BR>
<%/FOREACH%>
<%IF NO EVENTS EXIST%> <%/IF%>
</SPAN>
</TD>

The table cell itself was already in place, I merlly(sp?) hacked it to accept a different background color, depending on what category the event was in.  It dosn't work really well to have multiple category events within one hour, when I tested it, the first event category determined the cell color.

I've got a question for you, since you seem to be the leading mind in here. In the script above I've got another modification I'm working on:

<% if ($EVENT->{details}->{author_id} ne $User->{'Administrator'} ) { %>
<% if ($EVENT->{details}->{category} eq "appointment") {%>
Booked
<%} elsif ($EVENT->{details}->{category} eq "block") {%>
Unavailable
<%}%>
<% } elsif ($EVENT->{details}->{author_id} eq $User->{'Administrator'} ) { %>
<% if ($EVENT->{details}->{category} eq "appointment") {%>
<FONT SIZE="-2">[<A HREF="<%=$CGI_URL_QUERYSTRING%>view=Event&event_id=<%= EVENT FIELD(id) %>" STYLE="text-decoration:underline;">Appointment</A>]<BR></FONT>
<%} elsif ($EVENT->{details}->{category} eq "block") {%>
<FONT SIZE="-2">[<A HREF="<%=$CGI_URL_QUERYSTRING%>view=Event&event_id=<%= EVENT FIELD(id) %>" STYLE="text-decoration:underline;">Unavailable</A>]<BR></FONT>
<%}%>
<% } %>

I'm trying to make it so that only the admin, and eventually select users, will be able to view the details of a given event. At the moment I've managed to dissable all linking to details for the average user, but for what ever reason I've not managed to enable the Administrator to view the links to the details, even though I've got it set for the admin to see them.  I've covored all the points I can think of to make this work, mabe you can see something I don't?

Thanx!

-Ry : )

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

*edit the <TD> is out side of my <%FOREACH EVENT%> tags, so it dosn't really get created for each one, but the cell color does change depending on the category of the event.  Dynamic <TD>, gotta love it    

[This message has been edited by Audiodox (edited March 11, 2004).]

Logged
Scott
Guest
« Reply #3 on: March 11, 2004, 08:28:00 AM »

<% if ($EVENT->{details}->{author_id} ne $User->{'Administrator'} ) { %>

I think what you probably want is

<% if ($EVENT->{details}->{author_id} ne 'Administrator' ) { %>

?

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


Logged
Audiodox
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #4 on: March 11, 2004, 03:17:00 PM »

Success!

<% if ($User->{'username'} ne "Administrator") { %>
<%if ($EVENT->{details}->{category} eq 'appointment') {%>
Booked
<%} elsif ($EVENT->{details}->{category} eq 'block') {%>
Unavailable
<%}%>
<%} elsif ($User->{'username'} eq "Administrator") { %>
<%if ($EVENT->{details}->{category} eq 'appointment') {%>
<FONT SIZE="2">[<A HREF="<%=$CGI_URL_QUERYSTRING%>view=Event&event_id=<%= EVENT FIELD(id) %>" STYLE="text-decoration:underline;">Appointment</A>]</FONT>
<%} elsif ($EVENT->{details}->{category} eq 'block') {%>
<FONT SIZE="2">[<A HREF="<%=$CGI_URL_QUERYSTRING%>view=Event&event_id=<%= EVENT FIELD(id) %>" STYLE="text-decoration:underline;">Unavalable</A>]</FONT>
<%}%>
<%}%>

Tongue How could I not think of it!?!? The same bit is called all over the place, only with "anonymous" instead of "Administrator".  Well, that's done, now to disable the contents in list mode.  

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

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

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


WWW
« Reply #5 on: March 11, 2004, 03:32:00 PM »

** This is the full block... **

** The table cell itself was already in place, I merlly(sp?) hacked it to accept a different background color, depending on what category the event was in. **

** It dosn't work really well to have multiple category events within one hour, when I tested it, the first event category determined the cell color. **

I think you might find it may not display at all in some other (non-IE) browsers if multiple events are listed because (if I'm not mistaken) the original code printed events like this:

<TD CLASS="thinborder" BGCOLOR ...
event title here
event title here
event title here
event title here
...
</TD>

And if I read your code right (I haven't actually tested it) it looks like it would be printing out something like:

<TD CLASS="thinborder" BGCOLOR ...
event title here
<TD CLASS="thinborder" BGCOLOR ...
event title here
<TD CLASS="thinborder" BGCOLOR ...
event title here
<TD CLASS="thinborder" BGCOLOR ...
event title here
...
</TD>

That aint correct HTML code. Have you tried looking at the source code of the calendar to see exactly what you're printing out??

JFYI

Dan O.

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

Logged
Audiodox
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #6 on: March 11, 2004, 04:01:00 PM »

atm it looks something like this:

<TR>
<SPAN CLASS="text">
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">
<TR>
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">7:00 am </TD>
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" VALIGN=TOP><SPAN CLASS="text"> </SPAN></TD>
</TR>
<TR>
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">7:15 am </TD>
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" VALIGN=TOP><SPAN CLASS="text"> </SPAN></TD>
</TR>
<TR>
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">7:30 am </TD>
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" VALIGN=TOP><SPAN CLASS="text"> </SPAN>
</TD>
</TR>
<TR>
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">7:45 am </TD>
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" VALIGN=TOP><SPAN CLASS="text"> </SPAN>
</TD>
</TR>
</TD>
</SPAN>
</TR>

but that's because of my display (7:00,7:15,7:30,7:45 - dosn't work yet, just more cells atm).  Those are the empty cells, no events, here's with events:

<TR>
<SPAN CLASS="text">
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">
<TR>
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">6:00 am </TD>
<TD CLASS="thinborder" BGCOLOR="#444444" VALIGN=TOP><SPAN CLASS="text">•6:00 am-6:15 am:Booked<BR>•6:15 am-6:30 am:Unavailable<BR></SPAN></TD>
</TR>
<TR>
<SPAN CLASS="text">
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">
<TR>
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">6:15 am </TD>
<TD CLASS="thinborder" BGCOLOR="#444444" VALIGN=TOP><SPAN CLASS="text">•6:00 am-6:15 am:Booked<BR>•6:15 am-6:30 am:Unavailable<BR></SPAN></TD>
</TR>
<TR>
<SPAN CLASS="text">
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">
<TR>
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">6:30 am </TD>
<TD CLASS="thinborder" BGCOLOR="#444444" VALIGN=TOP><SPAN CLASS="text">•6:00 am-6:15 am:Booked<BR>•6:15 am-6:30 am:Unavailable<BR></SPAN></TD>
</TR>
<TR>
<SPAN CLASS="text">
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">
<TR>
<TD CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">6:45 am </TD>
<TD CLASS="thinborder" BGCOLOR="#444444" VALIGN=TOP><SPAN CLASS="text">•6:00 am-6:15 am:Booked<BR>•6:15 am-6:30 am:Unavailable<BR></SPAN></TD>
</TR>
</TD>
</SPAN>
</TR>

looks like all <TD> tags have a close, though I just noticed that the <SPAN> tags don't.  hmmm...

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

Logged
Audiodox
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #7 on: March 11, 2004, 04:06:00 PM »

hmmm... I just noticed that mozilla dosn't read the page as it displays it.  I'm gonna have to check out in IE & NS...

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

* nope, same stuff, so <TD> tags have a close, But the <SPAN> tags before them don't.  interesting.

[This message has been edited by Audiodox (edited March 11, 2004).]

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

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


WWW
« Reply #8 on: March 11, 2004, 04:17:00 PM »

** But the <SPAN> tags before them don't. **

Just a quick observation:

<TR>
<SPAN CLASS="text">
<TD
CLASS="thinborder" BGCOLOR="#EEEEEE" ALIGN="right" VALIGN="middle" WIDTH="125">
<TR>

You can not have a <SPAN> outside of a <TD> (unless it's around the whole table). You can also not have a <TR> inside of a <TD> tag like you appear to have.

Dan O.


[This message has been edited by DanO (edited March 11, 2004).]

Logged
Audiodox
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #9 on: March 11, 2004, 05:06:00 PM »

Okay, I started with a clean default.html and graphed on my hacks (-the whole :00 :15 :30 :45 thing, I'm gonna work that in later).  Code looks much cleaner now.

<TABLE BORDER="1" CLASS="thinborder" WIDTH=100%>
 <%FOREACH HOUR OF DAY%>
 <% next if (($HOUR < "6")); %>
 <%FOREACH EVENT%>
 <% if ($EVENT->{details}->{category} eq "appointment") {
   $cellcolor2="#4483D0";
 } elsif ($EVENT->{details}->{category} eq "block") {
   $cellcolor2="#444444";}%>
 <%/FOREACH%>
 <%IF NO EVENTS EXIST%>
    <%{$cellcolor2=$_GRID_CELL_BGCOLOR;}%>
 <%/IF%>

    <TR>
      <TD CLASS="thinborder" BGCOLOR="<%=$_GRID_CELL_BGCOLOR%>" ALIGN="right" VALIGN="middle" WIDTH="125">
         <SPAN CLASS="text">
         <% if ($HOUR == 99) { %>
           All Day Events
         <%ELSE%>
         <%=Date::formatTime(&Date::LZ($HOUR)."00",$Config->{'time_format'})%>
         <%/IF%>
         </SPAN>
      </TD>
      <TD CLASS="thinborder" BGCOLOR="<%=$cellcolor2%>" VALIGN=TOP>
      <SPAN CLASS="text">
         <%FOREACH EVENT%>
           <% if ($_SHOW_GRID_EVENT_BULLET) {%>•<%}%>
           <% if ($_SHOW_EVENT_TIMES eq "ALL" | | $_SHOW_EVENT_TIMES eq "START") { %>
              <% if ($EVENT->{'schedule'}->{'start_time'}) { %><%= SCHEDULE FIELD(start_time) %><% } %>
           <% } %>
           <% if ($_SHOW_EVENT_TIMES eq "ALL") { %>
              <% if ($EVENT->{'schedule'}->{'end_time'}) { %>-<%= SCHEDULE FIELD(end_time) %><% } %>
           <% } %>
           <% if (($_SHOW_EVENT_TIMES eq "ALL" | | $_SHOW_EVENT_TIMES eq "START") && ($EVENT->{'schedule'}->{'start_time'})) { %> : <% } %>
           <%= EVENT FIELD(title) %>
           <% if ($User->{'username'} ne "Administrator") { %>
              <%if ($EVENT->{details}->{category} eq 'appointment') {%>
                Booked
              <%} elsif ($EVENT->{details}->{category} eq 'block') {%>
                Unavailable
              <%}%>
           <%} elsif ($User->{'username'} eq "Administrator") { %>
              <%if ($EVENT->{details}->{category} eq 'appointment') {%>
                <FONT SIZE="2">[<A HREF="<%=$CGI_URL_QUERYSTRING%>view=Event&event_id=<%= EVENT FIELD(id) %>" STYLE="text-decoration:underline;">Appointment</A>]</FONT>
              <%} elsif ($EVENT->{details}->{category} eq 'block') {%>
                <FONT SIZE="2">[<A HREF="<%=$CGI_URL_QUERYSTRING%>view=Event&event_id=<%= EVENT FIELD(id) %>" STYLE="text-decoration:underline;">Unavalable</A>]</FONT>
              <%}%>
           <%}%>

           <BR>
           <%/FOREACH%>
           <%IF NO EVENTS EXIST%> <%/IF%>
           </SPAN>
      </TD>
    </TR>
 <%/FOREACH%>
</TABLE>

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

[This message has been edited by Audiodox (edited March 11, 2004).]

Logged
dc4622ne
New Member
*

Karma: 0
Offline Offline

Posts: 0

IT Specialist


WWW
« Reply #10 on: March 30, 2004, 08:37:00 AM »

anybody got an example of how this looks?

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

Logged
Zim
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #11 on: March 31, 2004, 07:57:00 AM »

Call me old fashioned for worrying about bandwidth, but the calendar is the #1 item in our web stats, and I was quickly/easily able to cut the per-page load size by almost 40% by moving the bgcolor, font, strong, etc into the style section at the top and assigning class names. Might be something to think about with this type of thing (I have colors assigned to my link types)

Cheers,
Mike

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

Logged
Audiodox
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #12 on: April 28, 2004, 03:42:00 PM »

@dc4622ne: look here
http://www.digitalillumination.org/cgi-bin/kimTemple/scheduling/calendar.pl?month=3&selected_datestring=20040312&datestring=20040312&view=Day#

I'm working on increments right now, so ignore the cells, but the shadeing looks good  

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

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