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] 2   Go Down
Print
Author Topic: Different categories idea  (Read 1442 times)
0 Members and 1 Guest are viewing this topic.
Pete
Guest
« on: March 23, 2002, 07:13:00 PM »

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

Logged
TubaDave
New Member
*

Karma: 0
Offline Offline

Posts: 0

Student


WWW
« Reply #1 on: March 24, 2002, 06:44:00 AM »

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/  


Logged

Scott
Guest
« Reply #2 on: March 24, 2002, 04:18:00 PM »

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!

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


Logged
Steven
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #3 on: March 24, 2002, 06:30:00 PM »

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...

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

Logged
Pete
Guest
« Reply #4 on: March 25, 2002, 07:05:00 AM »

Superb job, much appreciated.

P.

Logged
Curious
Guest
« Reply #5 on: April 05, 2002, 06:05:00 AM »

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.

Logged
tigran
Guest
« Reply #6 on: April 10, 2002, 04:34:00 PM »

Love the script thank you much for all the work.

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

Or any other type of category system.

Thanks

Logged
CalvertBrian
Guest
« Reply #7 on: June 19, 2002, 11:50:00 AM »

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.

Logged
CalvertBrian
Guest
« Reply #8 on: June 19, 2002, 02:46:00 PM »

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.

Logged
GotMyPT
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #9 on: July 04, 2002, 03:36:00 PM »

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

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

Logged
GotMyPT
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #10 on: August 10, 2002, 05:11:00 PM »

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


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

Logged
slh
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #11 on: October 02, 2002, 09:51:00 AM »

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

Logged
kstrange
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #12 on: October 02, 2002, 11:08:00 AM »


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


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

Logged
vitis
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #13 on: December 14, 2002, 09:33:00 PM »

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?

Logged
TotalHosting
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #14 on: March 28, 2003, 02:47:00 PM »

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

Logged

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