This is actually pretty easy.
1) Go to Calendar Administration -> Customize Event Fields and click on "Add New Field".
2) Give it a Display Name, make the Unique ID "category" (so the code below will work), and Description. You also probably want to make it a required field, but you don't have to. Leave the "Display in Add Form" and "Display in Details" as Yes.
3) Change Input Type to selectbox, and Pick a default value (one of the options).
4) Go down to the bottom, and start adding Categories. You need to put Both the Display Text and the Option Value (probably the same thing), then click add. Keep doing that until you have add all the options you want. Then click save.
Now you have added a category field to all your events. The fun part is writing a template that leaves out the events not in a specific category.
1) Just below the &getEvents line near the top of whichever template you are using, put this line before the closing %>:
$in{filter} | |= 'All';
2) Right after the <BODY> tag, or wherever you would like the dropdown to show up with all of options for filtering (as in if you only want it to show up in Grid view, only put it in the Grid view section of the template, etc.), put these lines of code:
<script language="javascript">
function filterSubmit (select)
{
location.href = "<%= $CGI_URL_QUERYSTRING %>" + select.name + "=" + select.value;
}
</script>
Filter events by category:
<select name="filter" onchange="filterSubmit(this)">
<option value="All" <%= $in->{'filter'} eq "All" ? "selected" : "" %> >All
<% $db = new DBFile($main::events_db);
@options = split /;/, $db->{'properties'}->{'category'}->{'options'};
while ($#options > 0) { $text = shift @options; $value = shift @options; %>
<option value="<%= $value %>" <%= $in{filter} eq $value ? "selected" : "" %> ><%= $text %>
<% } %>
</select>
3) Find the part of the template that actually displays the events (a quick way is to search for "FOREACH EVENT") and put this code right after the <%FOREACH EVENT%> tag:
<% if ($in{filter} eq "All" | | $in{filter} eq $EVENT->{'details'}->{'category'} | | $EVENT->{'details'}->{'category'} eq "" ) { %>
4) Finally, find the very next <%/FOREACH%> tag after each of the ones you put the code in step 3 after (don't just search for these tags, because there's a lot more of them), and put this code right before the <%/FOREACH%> tag:
<% } %>
And that will get you a main template that only shows the type of events the user has selected from a dropdown. If you didn't follow that last step, just email me you're template, and I'll make the necessary modifications to it.
Last but not least, you need to know how to make this work with an SSI template. Editing the template is the easy part, just repeat steps 1, 3, and 4 from above for the ssi template. The hard part is passing in the filter parameter to the template so it knows which part it is viewing. This topic has been discussed several times on this bulletin board, so search for "multiple ssi" or "include virtual" and see if you can figure it out first. You just want to pass filter=Meetings or filter=Socials, etc. to the script before it parses the ssi file. So far, all the methods that make that work require editing the calendar.pl file, so get ready for some code surgery! Alternatively, you could just use the main calendar view to show the filtered view of the events, and the single SSI will still show all events, regardless of category, without modification.
Good Luck on getting it to work!
David
------------------
David Whittaker
http://www.uabcm.com/
http://www.csworkbench.com/