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
Pages: [1]   Go Down
Print
Author Topic: Is there a better way  (Read 288 times)
0 Members and 1 Guest are viewing this topic.
k9barry
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« on: December 02, 2003, 05:35:00 PM »

I am using the following code in the default.html to change the color of the grid cell text based on the calendar the event came from.  I have modified it to work with MetaCalendar as well.

I was wondering if there was an easier way, mabey to be able to call the GRID_CELL_TEXT_COLOR for the calendar the event came from and use it there instead of hard coding the color?Huh??  

See code secment below.

      <%-- =============================== --%>
      <%-- THIS IS THE ACTUAL DISPLAY AREA --%>
      <%-- =============================== --%>

      <%-- MONTHLY OR WEEKLY VIEW --%>
      <% if ($VIEW eq "Month" | | $VIEW eq "Week" | | $VIEW eq "Two-Week" | | $VIEW eq "Three-Week" | | $VIEW eq "Four-Week") { %>
         <%-- GRID STYLE DISPLAY --%>
         <% if ($STYLE eq "Grid") { %>
            <TABLE BORDER="1" CLASS="thinborder" HEIGHT="100%" WIDTH="100%" CELLPADDING="2" CELLSPACING="1">
               <TR>
                  <%FOREACH GRID COLUMN%>
                  <TH CLASS="thinborder" BGCOLOR="<%=$_COLUMN_HEADER_BGCOLOR%>"><SPAN CLASS="columnheader"><%= $Grid->{'daynames'}->[$COL] %></SPAN></TH>
                  <%/FOREACH%>
               </TR>
               <%FOREACH GRID ROW%>
               <TR <%=$rowheight%>>
                  <%FOREACH GRID COLUMN%>
                  <% $i=0; %>
                  <TD CLASS="thinborder" VALIGN="TOP" WIDTH="14%" <%=$rowheight%> BGCOLOR="<%IF SELECTED%><%=$_GRID_CELL_SELECTED_BGCOLOR%><%ELSE%><%=$_GRID_CELL_BGCOLOR%><%/IF%>">
                     <%IF DISPLAY%>
                        <SPAN BGCOLOR="<%=$_GRID_DATE_BGCOLOR%>" CLASS="griddatetext"> <NOBR><A HREF="<%=$CGI_URL_QUERYSTRING%>selected_datestring=<%=$DAY->{'datestring'}%>&datestring=<%=$DAY->{'datestring'}%>&view=Day" CLASS="griddatetext"><%if($DAY->{'dd'}==1&&$VIEW ne "Month"){%><%=$DAY->{'monthname'}%> <%}%><%=$DAY->{'dd'}%></A> </NOBR></SPAN>
                        <%FOREACH EVENT%>
                           <%$i++;%>
                           <SPAN CLASS="gridtext">
<%
if ($EVENT->{details}->{calendarref} eq "day") {$color="#0000FF";}
elsif ($CALENDAR_KEY eq "day") {$color="#0000FF";}
elsif ($EVENT->{details}->{calendarref} eq "evening") {$color="#006600";}
elsif ($CALENDAR_KEY eq "evening") {$color="#006600";}
elsif ($EVENT->{details}->{calendarref} eq "midnight") {$color="#FF9900";}
elsif ($CALENDAR_KEY eq "midnight") {$color="#FF9900";}
elsif ($EVENT->{details}->{calendarref} eq "range") {$color="#FF0000";}
elsif ($CALENDAR_KEY eq "range") {$color="#FF0000";}
elsif ($EVENT->{details}->{calendarref} eq "training") {$color="#FFFF00";}
elsif ($CALENDAR_KEY eq "training") {$color="#FFFF00";}
elsif ($EVENT->{details}->{calendarref} eq "investigation") {$color="#996600";}
elsif ($CALENDAR_KEY eq "investigation") {$color="#996600";}
elsif ($EVENT->{details}->{calendarref} eq "holiday") {$color="#990000";}
elsif ($CALENDAR_KEY eq "holiday") {$color="#990000";}
elsif ($EVENT->{details}->{calendarref} eq "community") {$color="#000000";}
elsif ($CALENDAR_KEY eq "community") {$color="#000000";}
else {$color="$_GRID_CELL_TEXT_COLOR";}
%>
                           <FONT SIZE="<%=$_GRID_CELL_TEXT_SIZE%>"<FONT COLOR="<%=$color%>">>
                           <% 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'})) { %> : <% } %>
                           <A HREF="#" onClick="return gotolink('<%= $EVENT->{'details'}->{calendarref} %>', '<%=$CGI_URL_QUERYSTRING%>view=Event&event_id=<%= EVENT FIELD(id) %>&datestring=<%=$DAY->{datestring}%>&starttime=<%= &main::URLEncode($EVENT->{'schedule'}->{'start_time'}) %>&endtime=<%= &main::URLEncode($EVENT->{'schedule'}->{'end_time'}) %>')" CLASS="gridtext"><FONT COLOR="<%=$color%>"><%= EVENT FIELD(title) %> <%= EVENT FIELD(description) %></A><BR>
                           </FONT>
                           </SPAN>
                        <%/FOREACH%>
                        <% if ($i==0) { %><BR> <BR> <% } %>
                     <%/IF%>
                   
                  </TD>
                  <%/FOREACH%>
               </TR>
               <%/FOREACH%>
            </TABLE>
         <%-- END GRID STYLE DISPLAY --%>

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: December 02, 2003, 08:54:00 PM »

** mabey to be able to call the GRID_CELL_TEXT_COLOR for the calendar the event came from **

As far as i know, those values are stores in a file for each specific calendar. It would likely mean opening up that many additional files each time a calendar page is loaded. That would creat added server load (over and above what CalendarScript already uses).

It may be possible but I don't know the code to do it.

** I was wondering if there was an easier way **

If you are familiar with CSS, you could define some CCS cl;asses keyed on each calendar's name. That way you wouldn't need the all the if/else code but instead just add the calendar name to a tag to style the text. EG.

instead of

... CLASS="gridtext"><%= EVENT FIELD(title) %></A><BR>

use something like:


... CLASS="<%= $site_cal->{$EVENT->{details}->{calendarref}} #>"><%= EVENT FIELD(title) %></A><BR>

Dan O.

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

Logged
k9barry
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #2 on: December 02, 2003, 10:09:00 PM »

Thanks ofr the input, I will work on it and post anything If I have success.

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

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