We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23429
    • 2 Posts
    I have a new MODx site, being developed on 0.9.6.3, yesterday
    upgraded to 1.0.2 http://www2.aims.ac.za, almost done now.

    We use CALx. If there is no &mois=12 in the URL, and you click
    the forward month navigation in December, then the new URL is incorrectly
    set to mois=13. The modulo 12 only works if there was already a URL
    containing the month.

    I cannot open the modx site, it hangs for me:
    http://homeworks.dyndns.org/devcalx

    Below is a patch to fix it.

    0 jan@muizenberg:~$cat CALx.class.php_blank_url_month_modulo12_fix.patch
    --- CALx.class.php.orig 2009-12-15 09:49:09.000000000 +0200
    +++ CALx.class.php 2009-12-15 10:11:12.000000000 +0200
    @@ -948,12 +948,12 @@
    $strDayLink=’&jour=’.$this->jour;
    }
    $tempNextYear=$this->annee;
    - if($navMonth==12){
    + if($nextMonth==13){
    $nextMonth=1;
    $tempNextYear = $nextYear;
    }
    $tempPrevYear=$this->annee;
    - if($navMonth==1){
    + if($previousMonth==0){
    $previousMonth=12;
    $tempPrevYear = $previousYear;
    }
    @@ -1941,4 +1941,4 @@
    return false;
    }
    }
    -?>
    \ No newline at end of file
    +?>

    I’m not sure what other effect this has on the code, but it seems OK to me.


    Some other things I would like is to (easy) change the URL mois/anee to month/year in English,
    and (harder?) preserve the friendly portion of the URL, whereas CALx changes the early part to index.php?id=168 URL
    when navigating through dates.
      • 23429
      • 2 Posts
      I don’t know much about URL building or PHP at all, but this seems simple.
      Looks like CALx builds the URL here:

      $this->idDocSource=$modx->documentObject[’id’];
      $this->url_prefix = "index.php?id=" . $this->idDocSource;

      Would it be possible to preserve friendly URLs? I mean when I use the following
      URL manually, I get to the right page with the right calendar month/year
      displayed:

      http://www2.aims.ac.za/en/about/about-aims.html&mois=1&annee=2010

      But CALx itself will return to unfriendly when you use the month/year navigations
      (click one month forward):

      http://www2.aims.ac.za/index.php?id=5&mois=2&annee=2010

      Does documentObject[] have anything where I can get the index.php?id=5 replaced
      with the friendly part as above? Where does MODx keep the URL aliases and friendly
      URLs? Could CALx access this?
        • 4310
        • 2,310 Posts
        Thanks pipedream.
        I’m using CALx on three sites and each December I think "must try and fix the Month 13 problem", but never do sad
        The fix for the furl is at around line 506 :
         + $this->url_prefix=$modx->makeUrl(intval($this->idDocSource));
         - $this->url_prefix = "index.php?id=" . $this->idDocSource;

        Seems to work on the three sites I’v applied your fix to grin