UBBFriend: Email This Page to Someone!
  CalendarScript Support Forum
  Customization
  Different categories idea

Post New Topic  Post A Reply
profile | register | preferences | search

next newest topic | next oldest topic
Author Topic:   Different categories idea
Pete
unregistered
posted March 23, 2002 07:13 PM           Edit/Delete Message
Is there any way, or has anyone already customised events. For example: if the calendar was for an office you could have the following categories:

Meetings
Social
Projects
Deadlines

Then, using SSI I presume, could you show all events in a specific category?

Pete

IP: Logged

TubaDave
Member
posted March 24, 2002 06:44 AM     Click Here to See the Profile for TubaDave   Click Here to Email TubaDave     Edit/Delete Message
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/


IP: Logged

mkruse
Administrator
posted March 24, 2002 04:18 PM     Click Here to See the Profile for mkruse   Click Here to Email mkruse     Edit/Delete Message
In addition to the great help above, I thought I'd mention that I'm looking at including a "Allow Filter" option for each event field, and then having the templates have a built-in "Filter" popup that would let people restrict the display to only certain types of events. It seems to be a common request, so I thought I should probably build in some "official" support for the concept!

------------------
Matt Kruse
CalendarScript.com


IP: Logged

Steven
Junior Member
posted March 24, 2002 06:30 PM     Click Here to See the Profile for Steven   Click Here to Email Steven     Edit/Delete Message
I think the pop-up filter is a great idea. It could be applied so that you only view events of a certain type. Now, let's talk about extending this feature! Ok, assume someone logs in to the calendar and is presented with a pop-up field. They select their view options, what they what to see, whatever. Then, since they gave us their email address when they registered, you can send them daily/weekly/monthly emails of upcoming events based on the categories they chose. Now, this has not been very well thought out by me. There are a ton of variables and options that would need to be managed. Merely a thought...

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

IP: Logged

Pete
unregistered
posted March 25, 2002 07:05 AM           Edit/Delete Message
Superb job, much appreciated.

P.

IP: Logged

Curious
unregistered
posted April 05, 2002 06:05 AM           Edit/Delete Message
Hi :

Any idea when this feature will be available as a plugin or become a standard feature in the new release ? This seems to be an extremely useful feature.

IP: Logged

tigran
unregistered
posted April 10, 2002 04:34 PM           Edit/Delete Message
Love the script thank you much for all the work.

Does anybody have an example site for the modification mentioned above????

Or any other type of category system.

Thanks

IP: Logged

CalvertBrian
unregistered
posted June 19, 2002 11:50 AM           Edit/Delete Message
Anyone been able to get this to work cross-browser?

I've got it working great under IE, but Netscape fails. I even have it working with up to 3 filters simultaneously under IE, and it performs flawlessly.

In Netscape (tested 4.0 and 6.2), it seems to only pass 'filter=null'. I am sure it is something in the javascript, but I can't put my finger on it.

IP: Logged

CalvertBrian
unregistered
posted June 19, 2002 02:46 PM           Edit/Delete Message
Figured it out...

changed the function to

<script language="javascript">
function filterSubmit (select)
{
location.href = "<%= $CGI_URL_QUERYSTRING %>" + "filter" + "=" + select;
}
</script>

and the select statement to

<select name="filter" onchange="filterSubmit(this.form.filter.options[this.form.filter.selectedIndex].value)">

It works on NN 4, NN 6.2 and IE -- and I've instituted 3 different filters that work together. Our site is not ready to go live yet, and we are just testing this script. Now that we have it working we will probably end up using it. I'll post a link when we go live.

IP: Logged

GotMyPT
Junior Member
posted July 04, 2002 03:36 PM     Click Here to See the Profile for GotMyPT     Edit/Delete Message
CalvertBrian,

It's not working for me, any ideas? I have TubaDave's hack working just fine on IE, but not NS, all the list options are just printed across the page.

When I tried your hack choosing from the drop down does nothing, and there is an JS error, "object expected". I have several hacks done to my template, maybe there's a conflict? I'm not a programmer so I don't know how to debug this.

Can you double-check the code you posted here to see if it's correct?

GREATLY APPRECIATED

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

IP: Logged

GotMyPT
Junior Member
posted August 10, 2002 05:11 PM     Click Here to See the Profile for GotMyPT     Edit/Delete Message
CalvertBrian: I just tried to get several filter working together as you state you have done with 3, mine doesn't work.

I've done all the steps TubaDave outlined above changing where he says "category" to my field(s) "region" and "state". I've made this hack work just fine with ONE filter, but with TWO neither of them work. The drop downs show up and are populated, but choosing an item make the calendar show no events. Neither of the filters will work when I have 2 of them installed.

I don't know Perl, is there something I need to do to make the 2 filters (functions?) unique so they will work together?

Anyone? Help please!

THANKS!
Claudia


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

IP: Logged

slh
unregistered
posted October 02, 2002 09:51 AM           Edit/Delete Message
I have implemented the code above. However, my drop down box only shows "ALL". I have created a couple new FIELDS with UNIQUE EVENT ID's (catagories) with multiple options using a selection box.

Ideas?

TIA for any info

IP: Logged

kstrange
Junior Member
posted October 02, 2002 11:08 AM     Click Here to See the Profile for kstrange   Click Here to Email kstrange     Edit/Delete Message

Awesome tool, the filter's work great.

If anyone could help do multiple's that would be even better.

For example, I run a hockey league for my town and I have
a field called team, which contains our team names, and
another field for opponents. This is great for game
scheduling.

When we practice however it's always the same 2 teams
at the same times.

for example, Practice: Mite A & Mite B
I can't seem to get the filter to see 2 different text values in one field. (like search would)

-Kev


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

IP: Logged

vitis
Junior Member
posted December 14, 2002 09:33 PM     Click Here to See the Profile for vitis     Edit/Delete Message
Regarding the changed function for better cross-browser support:

I made the following changes (adapted from some other script that works) to the script and they worked on IE5.5, IE6, Opera 6. Could someone test on NS?

<script language="javascript">
function filterSubmit (selectObj)
{
var indexInt;
var filt;
indexInt = selectObj.selectedIndex;
filt = selectObj.options[indexInt].value;
location.href = "<%= $CGI_URL_QUERYSTRING %>" + "filter" + "=" + filt;
}
</script>

I left the select statement alone (well, reverted back to TurboDave's since I couldn't get CalvertBrian's post to work (same errors as others). Maybe a key item of the NS post was that the select statement also has to change in order for NS to work?

The original post and these changes have enabled me to totally change how my calendar is organized and presented. Excellent work! Thanks.

Oh, I haven't put any thought into this yet, but after the first usage of the filter it always appears twice in the URL (whether using the javascript or not - I have a non-javascript version too). I think I understand why, just not sure how to get rid of it. Any ideas?

IP: Logged

TotalHosting
Junior Member
posted March 28, 2003 02:47 PM     Click Here to See the Profile for TotalHosting     Edit/Delete Message
Hi.

Based on this concept of flagging different categories in the admin, how would you:

1) Display a differnt style or icon for each type of event in your master calendar (all meetings in BOLD RED, seminars in ITALIC BLUE, etc)

2) Create an SSI to include the month's list of events in their own pages (Meetings page, Seminars page, etc.)

3) Have a custom "no listings" message for each category in the above SSI

Thanks.

Pete

------------------
Pete
http://www.TotalHosting.com

IP: Logged

yullah
Member
posted April 16, 2003 02:01 PM     Click Here to See the Profile for yullah   Click Here to Email yullah     Edit/Delete Message
I can't get this feature to work at all... I've been playing with it for weeks... i'm just not a programmer by nature!

$20 paypal if someone would be willing to customise my script!

I need a search box feature right on the calendar (left margain near nav) that will search *all event fields*

and I need a drop down list that will filter events by location... (by state etc)

drop down search should return findings in the normal calendar view (grid & list) and the search box should return findings in list view as i have it set up.

also it is important that these functions work cross-browser

please email me if you can help me out with this!

thanks!!!

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

IP: Logged

kd4rdb
unregistered
posted April 23, 2003 09:58 AM           Edit/Delete Message
When listing a filter in the LIST view, the calendar will show a date for each event in the calendar even if no events are eligible to print. This is a little annoying, so what I did was to duplicate the 'foreach eventlist' loop and set $event_flag if any events showed up. Then, the second time thru the 'foreach eventlist', I print the date header if the $event_flag had been set indicating an event should be printed.
Wes

<%-- LIST STYLE DISPLAY --%>
<CENTER><TABLE BORDER="0" WIDTH="90%"><TR><TD ALIGN="left">
<SPAN CLASS="text">
<DL>
<%$total_events=0;%>
<%FOREACH EVENTLIST%>
<%$event_flag=0;%>
<%IF EVENTS EXIST%>
<%FOREACH EVENT%>
<% if (($in{filter} eq "All") or ($in{filter} eq $EVENT->{'details'}->{'category'}) or ($EVENT->{'details'}->{'category'} eq "" )) { %>
<% next if (($EVENT->{details}->{eventtype} eq "Private") and ($EVENT->{details}->{author_id} ne $User->{username}) ); %>
<% next if (($EVENT->{details}->{eventtype} eq "Employee") and ("anonymous" eq $User->{username}) ); %>
<%$event_flag=1;%>
<% } %>
<%/FOREACH%>
<%/IF%>

<%IF EVENTS EXIST%>
<%$total_events++;%>
<% if ($event_flag eq "1") {%><DT><B><A HREF="<%=$CGI_URL_QUERYSTRING%>selected_datestring=<%=$DAY->{'datestring'}%>&datestring=<%=$DAY->{'datestring'}%>&view=Day" CLASS="text"><%=$DAY->{dayname}%>, <%=$DAY->{monthname}%> <%=$DAY->{dd}%></A></B><DD><%}%>
<%FOREACH EVENT%>
<% if (($in{filter} eq "All") or ($in{filter} eq $EVENT->{'details'}->{'category'}) or ($EVENT->{'details'}->{'category'} eq "" )) { %>
<% next if (($EVENT->{details}->{eventtype} eq "Private") and ($EVENT->{details}->{author_id} ne $User->{username}) ); %>
<% next if (($EVENT->{details}->{eventtype} eq "Employee") and ("anonymous" eq $User->{username}) ); %>
<% 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="<%=$CGI_URL_QUERYSTRING%>view=Event&event_id=<%= EVENT FIELD(id) %>&datestring=<%=$DAY->{datestring}%>" STYLE="text-decoration:underline;" CLASS="text"><%= EVENT FIELD(machine) %> <%= EVENT FIELD(title) %></A><BR>
<% } %>
<%/FOREACH%>
<%/IF%>
<%/FOREACH%>
</DL>
<%unless($total_events){%>
<I><%= $_NO_EVENTS_LABEL %></I>
<% } %>
</SPAN>
</TD></TR></TABLE></CENTER>
<% } %>
<%-- END LIST STYLE DISPLAY --%>

[This message has been edited by kd4rdb (edited April 24, 2003).]

IP: Logged

mraj
Junior Member
posted February 25, 2005 11:21 PM     Click Here to See the Profile for mraj   Click Here to Email mraj     Edit/Delete Message
Instead of duplicating the eventlist loop, just do this:

<%-- LIST STYLE DISPLAY --%>
<CENTER><TABLE BORDER="0" WIDTH="90%"><TR><TD ALIGN="left">
<SPAN CLASS="text">
<DL>
<%$total_events=0;%>
<%FOREACH EVENTLIST%>
<%IF EVENTS EXIST%>
<%$total_events++;%>
<%my $eventsPerDay = 0;
my $header = "<DT><B><A HREF='${CGI_URL_QUERYSTRING}selected_datestring=$DAY->{'datestring'}&datestring=$DAY->{'datestring'}&view=Day' CLASS='text'>$DAY->{dayname}, $DAY->{monthname} $DAY->{dd}</A></B><DD>";%>

<%FOREACH EVENT%>
<%if($in{filter} eq "all" | | $in{filter} eq $EVENT->{'details'}->{'category'} or $EVENT->{'details'}->{'category'} eq "" ) { %>
<% if(++$eventsPerDay == 1) { print $header;} %>

New/modified lines are bold.
-- Mark

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

IP: Logged

mraj
Junior Member
posted February 25, 2005 11:27 PM     Click Here to See the Profile for mraj   Click Here to Email mraj     Edit/Delete Message
Note that if you copy and paste TubaDave's code (from post #2 above), you might have problems because '| |' has a space inbetween the first | and the second |. Remove any space.


This is not Dave's fault... seems to be a quirk with the bulletin board (because this post also has a space between | |).

[This message has been edited by mraj (edited February 25, 2005).]

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

CalendarScript Home