Tommy, aka trf from the phpWebSite forums had an idea. What, if it would be possible to filter your sites' calendar by its category? Like: You select the “Party” category and would only see all parties in your Calendar
Well, I've seen that idea, talked to Tommy and we implemented it. The whole project didn't even take a week and I got a very generous amount of money on my paypal account.
v7 (2005-03-10) instead of simply setting all checkboxes in the category selector to false when the Master category is selected, I commented the whole check out. This wasn't exactly a good idea as it generated an "invalid argument" warning during the foreach loop in CatSel.php. Fixed in this version
How it works | |
---|---|
The hack is spread across a couple of files
|
index.php | |
---|---|
I've divided the file in a couple of functions so it would be easier to handle. handle_admin_functions($command) and handle_user_functions($command) are the former admin / user dispatchers. before handling the given url, I set up the current filter with the new written set_up_filter() function. It retrieves the current filter from $_SESSION['cal_filter'] and sets it if it is requested through the current url. Next in line are the various new urls. cat_man calls the CatMan function of inc/CatMan.php, show_cat shows the current category-setup via a function included in index.php and cat_select calls the CatSelect function of inc/CatSelect.php. |
inc/CatMan.php | |
---|---|
The CatMan is very straight forward. If it gets the 'go' command, it will translate the current categories. If it doesn't, it shows all the categories together with the input-box. |
inc/CatSelect.php | |
---|---|
inc/CatSelect.php does pretty mutch the same like CatMan. But it shows checkboxes instead of the input-fields and doesn't store anything. After the user presses submit, he will be lead back to the last calendar-view he was on. This little piece of magic happens through the url -- I simply set up a hidden field called 'calendar[view]'. index.php takes care of the actual change. |
class/Display.php | |
---|---|
Every calendar-view has its own display function here. At the end of the functions, you'll usually see a final template-assignment and a call of that template. I've intercepted that and put the category in front. The function I wrote for that is called interpretFilter($filter, $new_view) , it gets the current filter as well as the name of the current view (year, month, etc.) The current view is needed for inc/CatSelect.php, so the user would be able to come back to his last view in case the user would want to change the filtering. |
class/Calendar.php | |
---|---|
I've introduced two new functions here: genRepeatsSQL() and genStraightSQL(). Both call the new master sql-generator that is the heart of the whole hack. genEventsSQL() gets a bunch of parameters. $fields contains the fields the calling method would like to have. The former calendar module used '*' here, but that would not work because of the joins going on now. $table tells genEventsSQL, which table to use. $startDate and $endDate limit the intervall, $filter contains the filter and $access tells, whether the user is allowed to view inactive events as well. |
Comments - Make a comment |
The comments are owned by the poster. We are not responsible for its content.
|
AdministrativeTexts
updated by freddiemac1993, 2013-06-14
wiki
Re: adventures
created by brittdavis10, 2012-02-23 (1 rply, 3 views)
thread
Re: how to run phpwebsite...
created by alexander, 2011-08-25 (2 rpls, 3607 views)
thread
Re: Forum tags
created by HaroldFaragher, 2011-08-22 (3 rpls, 8488 views)
thread