1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. To combat forum spam, new accounts will need to make at least one (valid) post.
    Otherwise, we will periodically purge all users without posts or that haven't confirmed their account.

Display multiple months

Discussion in 'General' started by keithh0427, May 29, 2005.

Thread Status:
Not open for further replies.
  1. keithh0427

    keithh0427 New Member

    Is there a way to display last month, this month, and next month? Similar to working on the events page of setup.
     
  2. ve9gra

    ve9gra Support Team

    If you reset the $mo variable before calling the listing module, it is possible. Add this
    PHP:
    $mo $mo 1;
    if (
    $mo == 0) {
        
    $mo 12;
        
    $yr $yr 1;
    }
    $listMonths 3;
    That should do the trick.
     
  3. Arthur

    Arthur New Member

    Thanks, ve9gra.

    Just one question: in what file/module is this code added, and where? I'd be grateful for fuller info as I'm a real n00b. Ta lot.
     
  4. keithh0427

    keithh0427 New Member

    This code would be placed in the HTML page that is calling the calendar.
     
  5. Arthur

    Arthur New Member

    Thanks.
    I must be really thick. Just tried adding this text but it still shows the single month, with the text across the top in one line, asin this test:

    www.williamson.co.za/test1.php
     
  6. keithh0427

    keithh0427 New Member

    You need to wrap it all in php

    Try this:

    <?php
    $mo = $mo - 1;
    if (
    $mo == 0) {
    $mo = 12;
    $yr = $yr - 1;
    }
    $listMonths = 3;
    ?>

    If you need this month and next month, it would be:

    <?php
    $mo = $mo + 1;
    if ($mo == 13) {
    $mo = 1;
    $yr = $yr + 1;
    }
    $listMonths = 3;
    ?>


     
  7. keithh0427

    keithh0427 New Member

    Just to be safe, here's some live code that I'm using.

    <?php
    echo "<table><tr>";
    $noNav = 1;
    echo "<td align=\"center\">";
    require("calendar/calendar.php");
    $mo++;
    if (++$mo > 12) {
    $mo = 1;
    $yr++;
    }

    echo "</td>";
    echo "<td align=\"center\">";
    require("calendar/calendar.php");
    $mo++;
    if (++$mo > 12) {
    $mo = 1;
    $yr++;
    }

    echo "</td>";
    echo "<td align=\"center\">";
    require("calendar/calendar.php");
    echo "</td>";
    echo "</tr></table>";
    ?>

    This will display 3 months in a horizontal fashion. You can increase the distance between the months by varying the table parameters such as padding, etc.

    Also, note the use of $noNav = 1;. You will need to use that to turn off the navigation beneath each calendar. Pretty messy if you don't.
     
  8. keithh0427

    keithh0427 New Member

    Arthur,

    Here's a complete .php file that I just tested.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <?php $CSS=1; require("calendar/calendar.php"); ?>
    </head>

    <body>
    <?php $OL=1; require("calendar/calendar.php"); ?>
    <?php
    echo "<table cellspacing='0' cellpadding='35'><tr>";
    $noNav = 1;
    echo "<td align=\"center\">";
    require("calendar/calendar.php");
    $mo++;
    if ($mo > 12) {
    $mo = 1;
    $yr++;
    }
    echo "</td>";
    echo "<td align=\"center\">";
    require("calendar/calendar.php");
    $mo++;
    if ($mo > 12) {
    $mo = 1;
    $yr++;
    }
    echo "</td>";
    echo "<td align=\"center\">";
    require("calendar/calendar.php");
    echo "</td>";
    echo "</tr></table>";
    ?>

    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </body>
    </html>
     
  9. keithh0427

    keithh0427 New Member

  10. ve9gra

    ve9gra Support Team

    So sorry Arthur... I had misunderstood your inquery. I thought you wanted to have 3 months displayed in the listing module and only the current month for the calendar.

    Here's the full code to what you want to do. Please make sure you adjust the paths accordingly to your installation.

    PHP:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Calendar</title>
    <?php $CSS=1; require("calendar/calendar.php"); ?>
    </head>

    <body>
    <?php $OL=1; require("calendar/calendar.php"); ?>
    <?php
    import_request_variables
    ("gp");
    if (!isset(
    $yr)) $yr=date("Y");
    if (!isset(
    $mo)) $mo=date("n");
    $lastMonth $mo 1;
    $lastYear $yr;
    if (
    $lastMonth == 0) { $lastMonth 12$lastYear--; }
    $curMonth $mo;
    $curYear $yr;
    $nextMonth $mo 1;
    $nextYear $yr;
    if (
    $nextMonth == 13) { $nextMonth 1$nextYear++; }

    echo 
    "<table cellspacing='0' cellpadding='35'><tr>";
    $noNav 1;
    echo 
    "<td align=\"center\">";
    $mo $lastMonth;
    $yr $lastYear;
    require(
    "calendar/calendar.php");
    echo 
    "</td>";
    echo 
    "<td align=\"center\">";
    $mo $curMonth;
    $yr $curYear;
    require(
    "calendar/calendar.php");
    echo 
    "</td>";
    echo 
    "<td align=\"center\">";
    $mo $nextMonth;
    $yr $nextYear;
    require(
    "calendar/calendar.php");
    echo 
    "</td>";
    echo 
    "</tr></table>";
    ?>
    </body>
    </html>
     
    Last edited: Jun 1, 2005
Thread Status:
Not open for further replies.

Share This Page