Board Logo

Display monthly events
williamkusumo - 7/22/2004 at 01:35 AM

Is it possible to display all the events in a month? I know a bit PHP but I need some clue which piece of code needs to be modified. Please help.

Thanks in advance,
William


texasaggie - 8/6/2004 at 05:47 PM

I was able to do this for monthly and annual events. The changes you'll need to make are in calendar.php and db.php.

In db.php, I found it easiest and quickest to create 2 new functions, one to read all monthly events and one to read all annual events. You just add iteration over 31 days and 12 months, respectively.

In calendar.php, I duplicated show_event and made new functions for displaying all events for a month and all for a year. I also had to modify the show_h and show_v to make the month name and year name in the calendar title a link to display monthly and annual.

In the end, I have 3 .php pages, one for daily, one for monthly and one for annual. Each calls a different function.


alain100 - 8/16/2004 at 05:55 PM

Hi,

this is awesome man. Would it be possible to post the code you use and where to do the changes.

thanks


texasaggie - 8/17/2004 at 12:36 AM

I was asked not to post the files in their entirety by SC but I did offer them back the code to include in the next version. I will post some snippets that should get most of what you need:

In db.php:

Copy the read_items function and call it read_monthly_items and make it take only 2 arguments - month and year. Then add a temp variable (I called it $l) and initialize it to 1. This is a counter to hold the index for all the events. Then wrap the if () check as follows:

for ($d = 1; $d <= 31; $d++) {
if (.....) {
$res[$l]=$v;
$l++;
}
}


It doesn't matter that you iterate over 31 days in months that don't have 31 days - you just don't find events. It simplifies the processing. You also have to not forget to increment the index, or else you end up overwriting things.

You can abstract things the same way for a read_items_yearly() type function. Just have an outer for loop that iterates the months ($m) from 1 to 12 and the inner loop the same as the monthly function.

Since I need a school/Scouting year calendar as well, I will probably sit down soon and write something that lets you choose a month and year and iterates from one to the other and gets all events in that range. I don't see it being that complicated.

The calendar.php changes were a bit more involved. I copied the show_event function and created 2 other methods as before. Take the arguments out and set up for loops as above to iterate.

Since you don't have a day in the month view to get the title, use a '1' place holder for the event date:

$event_date = date ('M, Y',mktime(0,0,0,$CLm,'1',$CLy));

Don't forget to delete the declaration and initialization for the days variable in the month function:

delete: $dp="CLd".$G_C;
delete: if(${$dp})$CLd=${$dp};


For the annual view, do the same thing that you did for the days to the month variables. The other trick is that I wanted to have a subheader in the table to break each month. To do this, in the yearly function that you create, inside the outer for loop for the months, set a variable as below to indicate it you used the month yet:

for ($m = 1; $m <= 12; $m++) {

$event_month_date = date ('M',mktime(0,0,0,$m,'1',$CLy));
$month_used=false;


Then inside the inner for loop, I added a link to that you could click on the month name and navigate to the month view of the calendar:

if(!$month_used) {
echo "<th colspan='4' align='left'><a href='pack_events_month.php?CLm=$m&CLy=$CLy'><span class='header1'>$event_month_date</span></a></th>";
$month_used=true;
}

I also changed the show_v and show_h functions to link the month and year in the header of the calendar to the pages that displayed those events. Those are not hard. Just copy the code that creates a link and set the URL to your other PHP page that processes the monthly or annual calendar view. Alternatively, you can have a header link that links to this.

If you email me directly, I'd be happy to answer any other questions in detail.


alain100 - 8/17/2004 at 04:08 PM

Thank you very much, I hope you don't get in trouble with SC because of me. They should hire you!!! You rock!!!

I'll try to set it up now. I hope I can make it work

thank again!!!!

Alain


BFG - 1/4/2005 at 03:27 PM

The demo looks brilliant. This is exactly what I need.

I had a look at modiflying the code to do this, and nothing seems to match. Was this a mod on an older version of event calendar?


DigitalOldschool - 1/12/2005 at 08:30 PM

I was wondering the same thing.
Has anyone managed to get this working with the latest version of PHP Event Calendar?


Vitoto - 3/18/2005 at 03:35 PM

Hi. man.

you can contrib by that file modifed for Display in Roll-Over Events ?


Thank you.


rdub - 3/30/2005 at 12:13 AM

Has anyone gotten this to work. It would be great.


texasaggie - 3/30/2005 at 04:52 PM

My mods were on the old version but I am working on extending those to the new version. The new version was a bit easier to deal with because the month display for the calendar days itself was done - all that was needed was to pull an event list together. I will post something when I get it done and take suggestions.


texasaggie - 4/1/2005 at 06:32 PM

I was able to get the changes to display monthly events working with the new 1.5.1 version. I also have permission from SoftComplex to post these here (thanks!). I still haven't completely finished what I want to get changed, but here's what I have so far. If you want to see how this works, see http://www.pack3040.org/calendar151/pack_events.php .


I put the calendar.php file here if you want to download it and view the changes. All of the changes are commented, so you can find them.

http://www.hollenshead.org/calendar151/calendar.php

For your month page, you will need to do the following to display the month view:

<?
$calendar->init('CalendarName');
$calendar->is_month_view = true;
$calendar->show_month();
?>

<?
$calendar->show_event_monthly();
?>

The annual view of events shouldn't be much harder but I haven't done it yet since the calendar display for the whole year takes up the entire screen and I'm not sure how I want to make it work. I currently use this on my annual page to display the full year calendar:

<?
$calendar->init('CalendarName');
$calendar->show_year();
?>

Changes:

* Display all events for a month, sorted by day.
* Change month and year title to be hyperlinked - month will take you to month display - year will take you to the year display
* Added variable to calendar to allow the admin/control panel to display the month differently
* New preferences to control alignment of cells when not in admin view
* Workaround for off by one bug in the annual display - the first month of the year in the SC year view for some reason decrements the year by 1 (i.e. reads Jan 2004 instead of Jan 2005)
* Fix typo in show_year() function

Limitations:

* Different web page/PHP page for monthly display vs. daily display vs. annual display (would be nice to get to one controlled by a parameter)
* Monthly and annual page names are not properties (yet!)
* New properties cannot be set in the control panel (yet!)
* Hyperlinks in events themselves are not working right. Something is prepending the URL of the site even though I have explicit markup in the event.


GMeagle86 - 4/2/2005 at 03:02 AM

Thanks!


bathory - 4/8/2005 at 06:43 AM

Hey Texasaggie,

Your fix worked beautifully and did exactly what I need, except the time/date replacement bit has made it so that they are merged together.

You can see my set up here http://idoru.ca/calendar.php
Ideally where it says the date bit (apr 25, etc) it should have a line break and then display the time, or at least a space. I tried tweaking this but I'm clearly not familiar enough with php to make it happen. Can you suggest something?

If there's any way to get it to say "Mon, Apr 25" as well that would amazing... I just don't read the code very well. Thank you :)


texasaggie - 4/8/2005 at 07:45 PM

I looked and I noticed that you still need to change the references to my pages ("calendar151/pack_events_monthly.php" and "calendar151/pack_events_annual.php") to "calendar.php". Otherwise, if you click on the month or year on the top of the calendar, it gives you a page not found.

As for the space, search calendar.php for "$time = date ('M d', $specific_date)" and add a space or <br> or whatever you need after the 'M d' --> 'M d ' or 'M d<br>'.

Let me know if that doesn't work.


con4mity - 5/2/2005 at 07:20 PM

Couple of things here, first, what exactly do you get when you add a space or break tag in the position you specified? I would think the answer would be nothing.

Instead you might try adding the blank space of the break in the concantenation string itself. For example:

Change this:
if($this->a_template['time_format'])
$time = date ('M d', $specific_date).($v->time_start['h']>11?($v->time_start['h']-12).':'.$v->time_start['m']." pm":$v->time_start['h'].':'.$v->time_start['m']." am").' -'.($v->time_end['h']>11?($v->time_end['h']-12).':'.$v->time_end['m']." pm":$v->time_end['h'].':'.$v->time_end['m']." am");
else $time = date ('M d', $specific_date).$v->time_start['h'].':'.$v->time_start['m'].' - '.$v->time_end['h'].':'.$v->time_end['m'];
}

to this:

if($this->a_template['time_format'])
$time = date ('M d', $specific_date).' '.($v->time_start['h']>11?($v->time_start['h']-12).':'.$v->time_start['m']." pm":$v->time_start['h'].':'.$v->time_start['m']." am").' -'.($v->time_end['h']>11?($v->time_end['h']-12).':'.$v->time_end['m']." pm":$v->time_end['h'].':'.$v->time_end['m']." am");
else $time = date ('M d', $specific_date).' '.$v->time_start['h'].':'.$v->time_start['m'].' - '.$v->time_end['h'].':'.$v->time_end['m'];
}

You'll notice I added a blank space after date ('M d', $specific_date).'blankspace'.$v->

Oh by the way, this was a great help to me. Do you know why my quotes inside the event listing are escaped and messing up the system? Is it magic quotes?


cregy - 5/3/2005 at 05:45 AM

Hi

I have used the monthly events list at:

<http://pulaski.cregy.net/calendar/index.php>

However, it is not listing the date. Could anybody tell me why?

I also seem unable to switch of the background colour to the table?!?

Thanks

Rich


dhender02 - 5/3/2005 at 07:17 PM

Change your event template to display time, rather than one of the other variables (i.e. num, body, etc.). Then it will display both time & date...... However, if you want it to look neat, you will have to modify the montly function to concatenate a space between date & time..... see http://cityofalexander.org/html/calender.phtml for example..

Good Luck.... Now if some one will help me with my question regarding admin password not working anymore...

David H.


wjthomas9 - 11/11/2005 at 05:51 PM

here's what I get after making the commented changes:

Warning: Unterminated comment starting line 517 in /home/oasisoo/public_html/php_event_calendar/cl_files/calendar.php on line 517

Parse error: parse error, unexpected $, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/oasisoo/public_html/php_event_calendar/cl_files/calendar.php on line 517

i can't seem to find what it's referring to. here's the address of the calendar page: http://www.oasisoo.com . I had a daily view working beautifully, but at a request I am trying to display monthly view. Just wondering what I did wrong. I appreciate your help with this.

jt


spinsane - 2/16/2006 at 08:52 PM

Quick Question,

I am using the displayed calendar on an html page and I wish to remove the links from the month and year that are displayed at the top of the calendar. Any Suggestions?


stealthboy - 2/27/2006 at 03:20 AM

I've input ur codes into my calendar and it works alright but it seems that the font size for the Cheader which is the "Month - Year" is very small. Where exactly do i go to edit the font size of the Cheader. I have tried including CSS styles to the page where i display my calendar but it seems that all the other attributes have their fonts altered except for the Cheader. Please help!


lintguy - 8/21/2006 at 11:19 AM

Quote:
Originally posted by spinsane
Quick Question,

I am using the displayed calendar on an html page and I wish to remove the links from the month and year that are displayed at the top of the calendar. Any Suggestions?


1. Open "calendar.php"
2. Search for: function show_header()
3. Within that function, replace this code:

<?echo $this->put_href($this->make_date($this->a_selected_date['m'],$this->a_selected_date
['y'],"M"),'/~chialpha/pack_events_monthly.php','',"CLy".$this->s_calendar_index."=".($this->a_selected_date
['y'])."&amp;CLm".$this->s_calendar_index."=".($this->a_selected_date['m']),'',1,'header')?> -
<?echo $this->put_href($this->make_date($this->a_selected_date['m'],$this->a_selected_date
['y'],"Y"),'/~chialpha/pack_events_annual.php','',"CLy".$this->s_calendar_index."=".($this->a_selected_date
['y']),'',1,'header')?>

with this (from the original file):

<?echo $this->make_date($this->a_selected_date['m'],$this->a_selected_date['y'],$this->a_template['title_format'])?>


Good luck


XTinitus - 10/3/2006 at 06:54 PM

Quote:
Message original : texasaggie
I was able to get the changes to display monthly events working with the new 1.5.1 version. I also have permission from SoftComplex to post these here (thanks!). I still haven't completely finished what I want to get changed, but here's what I have so far. If you want to see how this works, see http://www.pack3040.org/calendar151/pack_events.php .


I put the calendar.php file here if you want to download it and view the changes. All of the changes are commented, so you can find them.

http://www.hollenshead.org/calendar151/calendar.php


Unfortunately, this link is broken. Is someone knows the code or owns the file? All I need is the function show_event for the month (show_event_monthly) part. I will really appreciate any help.
Thank's a lot.
Richard


XTinitus - 10/14/2006 at 06:03 AM

Statistically, there have been 5510 visits to this page at the moment, and not only one answer or comment. His a solution even exists?


misty - 4/21/2007 at 04:49 AM

Yes, I would like to see the function for the show_event_monthly as well. Can some post the function? Because unfortunately the link above to the source is broken.


tigra - 4/27/2007 at 03:54 PM

I'll ask the developer responsible for php event calendar to take a look at this.


dlpirl - 5/11/2007 at 05:11 PM

Another request to be able to list weekly, monthly or yearly events.


kvv - 5/22/2007 at 03:09 PM

To be able to display monthly events you need to replace calendar.php and events.php files with its updated copies attached.

The new function is:

$calendar->show_month_event()

PS: DON'T FORGET TO CHANGE PATH at the top of calendar.php file.


XTinitus - 5/24/2007 at 09:46 AM

Wow, this is so cool. Thank you very much!


crh0872 - 6/13/2007 at 10:12 PM

kvv,

after installing your patch, it works great except that when I switch to a month that doesn't have any events, i get the following error message:

Warning: Invalid argument supplied for foreach() in /*****/calendar/cl_files/events.php on line 115

Can you help me?

Thank you


beguiner - 6/23/2007 at 12:01 PM

Quote:
Originally posted by crh0872
kvv,

after installing your patch, it works great except that when I switch to a month that doesn't have any events, i get the following error message:

Warning: Invalid argument supplied for foreach() in /*****/calendar/cl_files/events.php on line 115

Can you help me?

Thank you


Hi, IA?m spanish and donA?t writte english well, sorry, but i have same problem and my solution is :

You can hide this error message :
@$calendar->show_month_event();

the @ symbol hide the error message in the functtion and in the months that havenA?t events no show the error message and the months that have events show well.

NOTE: this solution hide error mesasse only but the rest of script run well

I hope help you


dante_in_Calgary - 6/25/2007 at 05:18 AM

I got the monthly event summary to work and initially it wasn't sorting but then KVV did a fix to the class file and all was good. Now I'm wanting (on a different page) to show the weekly event list and I can't seem to get anything but blank when I change the code back from $calendar->show_month_event(); to $calendar->show_event();

Is it because the class files changed and that now it can only show monthly?

I'm Perplexed!


kvv - 6/25/2007 at 03:00 PM

New class file allow show events by day $calendar->show_event().
If you have a problem with it please post your ticket in the support system http://www.softcomplex.com/support/ .


kvv - 6/27/2007 at 08:46 AM

For all who have sorting problem with monthly view.

Please use updated files attached.
If you already use files from Update_22_05.zip you need to replace events.php file with it updated copy attached (Update_27_06.zip).
The other users need to use both files (calendar.php and events.php)


kvv - 12/20/2007 at 05:16 PM

Do you use update_27_06.zip ?


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/