PDA

View Full Version : multiple (3) calendars in a row


hiscores
03-09-2004, 08:09 PM
Hi, the script works great, set up was simple, and everything is working as of right now. Of course I want to modify a few things, to our use, and the first thing is that on the 'calendar' page I want to display 3 of the calendars (in a row, though vertically could work too), starting with of course this months calendar, and then showing the next two months after.

I'm sure this is a simple thing, but I haven't been able to find the question addressed elsewhere. Can anyone help?

Since the line of code in my .php page calls another document, I'm wondering where I would tell it to print 3, and how I would also tell it to make the 2 additional calendars the next subsequent months in the calendar year from todays date.

Many thanks,
HS

tomB
03-09-2004, 08:42 PM
You will need to use tables in demo.php.

To change the month and year the variables are $mo and $yr.

use a table structure of:
table
table row1
table data1
<div align="center">
<?php require ("showCalendar.php"); ?>
</div>
end data1
table data2
<div align="center">
<?php
$mo++;
if ($mo==13) {$mo=1; $yr=$yr+1;}
require ("showCalendar.php");
?>
</div>
end data2
table data3
<div align="center">
<?php
$mo++;
if ($mo==13) {$mo=1; $yr=$yr+1;}
require ("showCalendar.php");
?>
</div>
end data3
end row1
end table

this will give you three calendars across.

Changing the number of rows and columns will yield three calendars stacked.

You will need to turn off the navigation controls other wise they will show
at each calendar (messy!).

Also before the table the first calendar will need to be preset for year and
month as so:

if(!$mo) $mo=date("m"); // set current month
if(!$yr) $yr=date("Y"); // set current year
$yb=$yr;
$yf=$yr;
$mb=$mo-3;
if ($mb<1) {$mb=$mo+9; $yb=$yr-1;}
$mf=$mo+3;
if ($mf>12) {$mf=$mo-9; $yf=$yr+1;}

$yf, $yb, $mf, and $mb are used in your own navigation controls to increment decrement the month and year by three.

Good luck,
tomB

hiscores
03-09-2004, 10:00 PM
Thank you, Tom. I shall work on what you gave me, and let you know how it goes for future users. I appreciate the timely response.

hiscores
03-10-2004, 02:02 PM
Tom,

this will give you three calendars across.
And indeed it did! I just followed your instructions and placed the code in my .php document that calls the calendar. How very nice.

You will need to turn off the navigation controls other wise they will show at each calendar (messy!).
Yes, agreed, it is messy. But I would really like to have an advance and previous graphic or text link, there, and I was wondering how I can go about doing that. I think you make reference to this when you say:

$yf, $yb, $mf, and $mb are used in your own navigation controls to increment decrement the month and year by three.

If I turn off the controls, is there a line of code that I can place in a table row directly below the three calendars that will contain essentially the forward/back links?

Can I have it advance ONE month at a time (advancing from MAR-APR-MAY will then display APR-MAY-JUN for example), or will it always have to advance the full 3 months from the last displayed?

I can see the link that the far right (3rd) calendar table displays when I mouseover the forward arrow, but I think that is generated dynamically and so I'm not sure what/where to place within the document to replicate this.

Also, one side question, as you may know the answer. Can I somehow pull the code that generates the pulldown above the calendar in the admin section? The pulldown lets you jump to whatever month you'd like, and it sure would be nice to have that as one final option for viewers of the calendar, in case they want jump say 8 months in advance, without having to do one at a time.

Beyond that, thanks so much for the help, it made the three calendars (or however many people may want in the future) very easy to implement!

-Hs

tomB
03-10-2004, 02:59 PM
If I turn off the controls, is there a line of code that I can place in a table row directly below the three calendars that will contain essentially the forward/back links?
A simple navigation bar added as another row to your calendar table:
table row
table data
new table
table row
table data1 [align="left" width="20%"]
<a href="<?php echo $PHP_SELF."?mo=".($mb)."&yr=".$yb; ?> "><<Prev</a>
end data1
table data2 [ align="center" width="60%"]
<a href="<?php echo $PHP_SELF; ?>">-Current-</a>
end data2
tavble data3 [ align="right" width="20%"]
<a href="<?php echo $PHP_SELF."?mo=".($mf)."&yr=".$yf; ?>">Next>></a>
end data3
end row1
end new table
end data
end row

Also, one side question, as you may know the answer. Can I somehow pull the code that generates the pulldown above the calendar in the admin section? The pulldown lets you jump to whatever month you'd like, and it sure would be nice to have that as one final option for viewers of the calendar, in case they want jump say 8 months in advance, without having to do one at a time.

Yes, if you go to the 'Hacks & Modification' section you will find the calendar with a tabular listing. Part of that is a form 'sel_month.php' This can be inserted into a table element, as is done in the file 'events.php'

Can I have it advance ONE month at a time (advancing from MAR-APR-MAY will then display APR-MAY-JUN for example), or will it always have to advance the full 3 months from the last displayed?

Yes, just change the increment/decrement for $mf, $mb to one.

tomB

hiscores
03-11-2004, 10:30 AM
A simple navigation bar added as another row to your calendar table:
This worked perfectly, thank you.

Yes, just change the increment/decrement for $mf, $mb to one.
This worked perfectly as well, thank you.

Yes, if you go to the 'Hacks & Modification' section you will find the calendar with a tabular listing. Part of that is a form 'sel_month.php' This can be inserted into a table element, as is done in the file 'events.php'
I'm having problems with this one, specifically entering JUST the code for the pulldown, and not 6 month or the MS Outlook parsing, etc. I don't know which of those three files I need. Maybe you can help one last time in telling me what section of that code I need (the sel_month.php) and what, if any, other code is necessary from neatcal.php or the events.php?

My main calendar page is called calendar.php (which would be the same as your neatcal.php if I am not mistaken). It resides outside of the 'escal' directory, but calls into it no problem. I am runnign from SQL database, not flatfile based.

tomB
03-11-2004, 01:52 PM
The original version of the form I used had some "proprietery" variable names.
I have since modified it to use the variables in 'escal.php'.

Try this version:
<form name="form1" method="post" action="demo.php">
<div align="right">
&nbsp;<table border="1" cellpadding="2" cellspacing="0">
&nbsp; <tr>
&nbsp; &nbsp;<td>
&nbsp; &nbsp; <? $currentMonth = date("M"); if (!@$fmnth) $fmnth=date("M");?>
&nbsp; &nbsp; <select name="month" id="month">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<?
&nbsp; &nbsp; &nbsp; &nbsp; $sel="";
&nbsp; &nbsp; &nbsp; &nbsp; foreach ($mth as $fmnth) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($fmnth==$mth[$mo]) {$sel="selected";}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else {$sel="";}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "<option $sel>$fmnth </option>";
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;?>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</select>&nbsp;
&nbsp; &nbsp; &nbsp;<? $currentYear = date("Y"); &nbsp;?>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<select name="year" id="year">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <?
&nbsp; &nbsp; &nbsp; &nbsp; $sel="";
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for($fvyr = $currentYear-1; $fvyr <= ($currentYear+1); $fvyr++) {
&nbsp; &nbsp; &nbsp; if($fvyr==$yr) {$sel="selected";}
&nbsp; &nbsp; &nbsp; else {$sel="";}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo "<option $sel>$fvyr </option>";
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ?>
&nbsp; &nbsp; &nbsp;</select>
&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<input type="submit" name="Submit" value="Select">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</td>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </tr>
&nbsp; &nbsp; &nbsp; </table>
</div>
</form>

hiscores
03-11-2004, 02:49 PM
I'm still not getting it, but feel close, so I'll try to step it out plainly and see where I go wrong. I have my calendar set up nicely, the document lists 3 months across, is called "calendar.php".
In a new table row underneath my nav (prev/current/next) I want to place this pulldown menu.

I create the table row:

<tr>
<td colspan="3">XXXXXXXXXX</td>
</tr>

What do I put in the XXXXX? Do I put the form code you just supplied (i tried that and had error)? Do I put the php code linking to another document (such as <?php include "escal/events.php"; ?>). Yes, my calendar.php resides outside of the 'escal' directory, which I think is fine?

If I link to "events.php" via that line of code, do I then just create a new php document with the entire contents of your other post regarding the 'events.php' code? Save that, upload into the 'escal' directory? Then do the same for the Sel_month.php document? Create a new one with only the code from your post, and place it in the escal folder, too? That's what I've done so far, and I get:

Parse error: parse error in /usr/www/users/XXXX/XXXXXXXX/escal/events.php on line 44
Which in events.php code is this:

if(file_exists("outlook.CSV")){ // does the file exist?

Sorry this is not working yet, I appreciate your patience.

tomB
03-12-2004, 01:29 PM
In a new table row underneath my nav (prev/current/next) I want to place this pulldown menu.

I create the table row:

<tr>
<td colspan="3">XXXXXXXXXX</td>
</tr>


For XXXXXXXXXXXXX insert:
<table>
&nbsp;<tr>
&nbsp;<td >
&nbsp; <?php &nbsp; &nbsp;require ("/escal/sel_month.php"); ?>
&nbsp;</td>
&nbsp;</tr>
&nbsp;</table>


if(file_exists("outlook.CSV")){ // does the file exist?
This is for reading comma seperated variable files from an MS Outlook calendar. You definetly don't need this.

Events.php is for displaying a tabular listing of the months events. My understanding is that you only want to jump to a month for the calendar. You don't need it.

What you do need at the top of 'calendar.php' is the following:
<?php
if (!isset($mo)) $mo=date("n");
if (!isset($yr)) $yr=date("Y");
// Get the starting month for the tabular listing //
$MM = $HTTP_POST_VARS['month'];
if ($MM!=NULL) { // this comes from sel_month.php POST
&nbsp; foreach($mth as $ndx=>$MN) {
&nbsp; &nbsp; if ($MM==$MN) break;
&nbsp; &nbsp;}
&nbsp; &nbsp;$mo = $ndx;
&nbsp; &nbsp;$yr = $HTTP_POST_VARS['year'];
}

?>

This will get the POSTED entries from sel_month.

tomB

tomB
03-12-2004, 06:44 PM
Sent email with solution (tested!) :)

tomB