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: Template Query  (Read 405 times)
0 Members and 1 Guest are viewing this topic.
Fasta
Guest
« on: November 18, 2003, 10:24:00 AM »

I have a main calendar for my school that all school events and sport events are entered into.  This is great!  The problem comes in when I display a template on the front page of the web site (http://www.spx.org/).  I do not want all events displayed there.  I have added an event field called "front_page" whose options are "Yes" and "No".  I only want events in which “front_page”=”Yes” to be displayed.  In the past, to filter content out of a template I added a line of code.  In this case it would be:
<% next if ($EVENT->{details}->{front_page} ne "Yes"); %>  
in the <%FOREACH EVENT%> sections.  This works great in Grid view, but in my template’s view (http://lion.spx.org/calendar/calendar.pl?template=homepage.html) this would leave gaps and lots of blank spaces for events that were skipped.  It also brings up days that I have no events for.  With all the smart people and ideas on this forum, I am hopeful that someone can help me with this.
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: November 18, 2003, 01:39:00 PM »

** this would leave gaps and lots of blank spaces for events that were skipped. It also brings up days that I have no events for. **

You likely mean it displays dates which have no events to display on. There must be some events on that date somewhere or else that date likely shouldn't display at all.

** I am hopeful that someone can help me with this. **

Fairly unlikely without being able to see what code is being used in the homepage.html template

You'll likely have to make a conditional before where the date table cell is output. That may involve looping through the events twice, one to see if any events will be displayed for a particular date and once for where they're actually printed.

Dan O.


[This message has been edited by DanO (edited November 18, 2003).]

Logged
Fasta
Guest
« Reply #2 on: November 18, 2003, 02:17:00 PM »

Here is the code for the current homepage.htm:

<%
&getEvents( {'duration'=>'5d'} );
$total_events=0;
%>
<style>
th
{
   font : 18px "Times New Roman", Times, serif;
   text-align : center;
   color : #F7E79C;
   background-color : #003374;
   padding-top : 3px;
   padding-bottom : 3px;
}

A.minical { text-decoration:none; }
A.minical:hover { text-decoration:underline; }
.minical { color:black; }

.day
{
   font: 15px verdana, Geneva, Arial, Helvetica, sans-serif;
   color : #003374;
   padding: 10px;
   border-left : 1px solid;
   border-left-color : #003374;
   border-bottom : 1px solid #003374;
   border-right: 1px solid;
   border-right-color: #003374;
}

.eventstart
{
   font: 11px verdana, Geneva, Arial, Helvetica, sans-serif;
   color : gray;
   border-bottom : 1px solid;
   border-bottom-color : #003374;
   border-right : 1px solid;
   border-right-color : #003374;
   padding: 5px;
}
</style>

<BODY style="margin:0px">

   <TABLE cellpadding="0" cellspacing="0" width="300" border="0">
      <TR>
         <TH colspan="3">A Glance at the Next 5 Days</TH>
      </TR>
 <%FOREACH EVENTLIST%>
 <%IF EVENTS EXIST%>
 <%$total_events++;%>
 <%$curr_events=0;%>
 <%FOREACH EVENT%>
 <%$curr_events++;%>
 <%/FOREACH%>
      <TR>
         <TD class="day" width="25" rowspan="<%=$curr_events%>"><%=$DAY->{dayabbreviation}%>
            <BR><%=$DAY->{'dd'}%></TD><%$curr_events=0;%><%FOREACH EVENT%>
               <% if ($curr_events) { %><% } $curr_events++; %>
         <TD class="eventstart"> <A HREF="http://lion.spx.org/calendar/calendar.pl?view=Event&event_id=<%= EVENT FIELD(id) %>" target="_blank" class="minical">
     <%=$EVENT->{'details'}->{'title'} %></a></TD>
         <td class="eventstart" width="50"><% if ($EVENT->{'schedule'}->{'all_day'}) { %>
      -  
     <% } else { %>
     <% SCHEDULE FIELD(start_time) %><% } %></td>
       </TR>
       <%/FOREACH%>
 <%/IF%>
 <%/FOREACH%>
 <%unless($total_events){%>
      <TR>
         <TD colspan="3"><IMG src="images/spacer.gif" width="1" height="25" alt="" border="0"></TD>
      </TR>
        <% } %>
   </TABLE>
</BODY>

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

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


WWW
« Reply #3 on: November 18, 2003, 04:38:00 PM »

Try changing the code block:

<%IF EVENTS EXIST%>
<%$total_events++;%>
<%$curr_events=0;%>
<%FOREACH EVENT%>
<%$curr_events++;%>
<%/FOREACH%>
<TR>

to:

<%$curr_events=0;%>
<%FOREACH EVENT%>
<%
next if ($EVENT->{details}->{front_page} ne "Yes");
$total_events++;
$curr_events++;
%>
<%/FOREACH%>
<%if ($total_events) { %>
<TR>

Then making an additional conditional to skip printing of the unwanted events.

 This code is untested so use at your own risk. Always keep a backup of original files.

Dan O.

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

Logged
Fasta
Guest
« Reply #4 on: November 19, 2003, 08:15:00 AM »

Thank you!  It works great!

One more request of a cosmetic nature.  If there are no events for a particular day, I need that day to disappear or have it print out one blank event (perhaps a spacer gif) so that it doesn’t leave a hole in the table.

See what I mean at:  http://lion.spx.org/calendar/calendar.pl?calendar=default&template=homepage7.html

Here is my current code:

<%
&getEvents( {'duration'=>'7d'} );
$total_events=0;
%>
<style>
th
{
   font : 18px "Times New Roman", Times, serif;
   text-align : center;
   color : #F7E79C;
   background-color : #003374;
   padding-top : 3px;
   padding-bottom : 3px;
}

A.minical { text-decoration:none; }
A.minical:hover { text-decoration:underline; }
.minical { color:black; }

.day
{
   font: 15px verdana, Geneva, Arial, Helvetica, sans-serif;
   color : #003374;
   padding: 10px;
   border-left : 1px solid;
   border-left-color : #003374;
   border-bottom : 1px solid #003374;
   border-right: 1px solid;
   border-right-color: #003374;
}

.eventstart
{
   font: 11px verdana, Geneva, Arial, Helvetica, sans-serif;
   color : gray;
   border-bottom : 1px solid;
   border-bottom-color : #003374;
   border-right : 1px solid;
   border-right-color : #003374;
   padding: 5px;
}
</style>

<BODY style="margin:0px">

   <TABLE cellpadding="0" cellspacing="0" width="300" border="0">
      <TR>
         <TH colspan="3">A Glance at the Next 7 Days</TH>
      </TR>
 <%FOREACH EVENTLIST%>
 
<%$curr_events=0;%>
<%FOREACH EVENT%>
<%
next if ($EVENT->{details}->{front_page} ne "Yes");
$total_events++;
$curr_events++;
%>
<%/FOREACH%>
<%if ($total_events) { %>
<TR>
      
         <TD class="day" width="25" rowspan="<%=$curr_events%>"><%=$DAY->{dayabbreviation}%>
            <BR><%=$DAY->{'dd'}%></TD><%$curr_events=0;%><%FOREACH EVENT%>
               <% if ($curr_events) { %><% } $curr_events++; %><% next if ($EVENT->{details}->{front_page} ne "Yes"); %>
         <TD class="eventstart"> <A HREF="http://lion.spx.org/calendar/calendar.pl?view=Event&event_id=<%= EVENT FIELD(id) %>" target="_blank" class="minical">
     <%=$EVENT->{'details'}->{'title'} %></a></TD>
         <td class="eventstart" width="50"><% if ($EVENT->{'schedule'}->{'all_day'}) { %>
      -  
     <% } else { %>
     <% SCHEDULE FIELD(start_time) %><% } %></td>
       </TR>
       <%/FOREACH%>
 <%/IF%>
 <%/FOREACH%>
 <%unless($total_events){%>
      <TR>
         <TD colspan="3"><IMG src="images/spacer.gif" width="1" height="25" alt="" border="0"></TD>
      </TR>
        <% } %>
   </TABLE>
</BODY>

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: November 19, 2003, 01:12:00 PM »

** If there are no events for a particular day, I need that day to disappear **

That is what the code I supplied is suppose to do so I guess it isn't working properly. Try changing the line:

<%if ($total_events) { %>

to

<%if ($curr_events) { %>

to see if it makes a difference.

Dan O.

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

Logged
Fasta
Guest
« Reply #6 on: November 20, 2003, 08:13:00 AM »

That did it!  Thank you very much!
Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

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


WWW
« Reply #7 on: November 20, 2003, 08:59:00 PM »

Glad to hear it.

Dan O.

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

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