ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Yet Another Calendar Question!

September 25, 2007 12:03am

Subscribe [0]
  • #16 / Sep 25, 2007 4:17pm

    e-man

    1816 posts

    You need a bit more checking and 2 loops but this should basically give you what you need:

    <?php 
        $month = ltrim("{segment_3}", 0); // trim leading 0
        $year = "{segment_2}";
        $base_url = "http://www.retinadance.com/index.php/calendar/"; // for convenience sake, add your own url here
        $the_months = array("","january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"); //names of the months, first empty element takes care of the 0 counter
        ?>
        <ul>
        <?php
        $month=$month-3;
        switch ($month) {
            case '-2':
                $month=10;
                $year--;
                break;
            case '-1':
                $month=11;
                $year--;
                break;
            case '0':
                $month=12;
                $year--;
                break;
        }
        for ($i=0; $i < 3 ; $i++) { 
            if ($month<10) {
                echo "<li><a >"."$the_months[$month]"."</a></li>";
            } else {
                echo "<li><a >"."$the_months[$month]"."</a></li>";
            }
            $month++;
                if ($month > 12) {
                    $month=1;
                    $year++;
                };
        }
    
        $month = ltrim("{segment_3}", 0); 
        for ($i=0; $i < 4 ; $i++) { 
            if ($month<10) {
                echo "<li><a >"."$the_months[$month]"."</a></li>";
            } else {
                echo "<li><a >"."$the_months[$month]"."</a></li>";
            }
            $month++;
                if ($month > 12) {
                    $month=1;
                    $year++;
                };
        }
        ?>
        </ul>
  • #17 / Sep 25, 2007 4:23pm

    jschutt

    452 posts

    Amazing!  Thanks for taking time to work this out for me! 

    I guess that I will need to be learning some PHP in the future.

  • #18 / Sep 25, 2007 4:25pm

    jschutt

    452 posts

    Just out of curiosity -

    event calendar

    Will this cause any problems since it is returning only one digit for the month?

  • #19 / Sep 25, 2007 4:30pm

    e-man

    1816 posts

    Substitute (“m”) for (“n”) and you should have your leading 0 back. It never gave me a problem on the Retina site though.

  • #20 / Sep 25, 2007 4:44pm

    jschutt

    452 posts

    Great - Thanks!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases