We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11055 ☆ A M B ☆
    • 3,112 Posts
    have you tried to change the .css files?
      Rico
      Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
      MODx is great, but knowing how to use it well makes it perfect!

      www.virtudraft.com

      Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

      Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

      Maintainter/contributor of Babel

      Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
      • 8893
      • 4 Posts
      I am having exactly the same problem as SMF - no formatting. When trying to use the default calendar, mine looks exactly the way his/her image shows above.

      I haven’t made any changes to the CSS files.

      Does anyone have suggestions? SMF, did you figure out the cause of the problem?

      Thanks so much,
      Elizabeth
        • 8893
        • 4 Posts
        I finally figured it out - I had to add the CSS calls to the head content of my document template. I added the following lines:

        <link href="http://(mydomain)/assets/snippets/calendar/templates/default/calendar.css" media="screen" rel="stylesheet" type="text/css" />
        <link href="http://(mydomain)/assets/snippets/calendar/templates/mini/calendar.css" media="screen" rel="stylesheet" type="text/css" />
        <link href="http://(mydomain)/assets/snippets/calendar/templates/ical/calendar.css" media="screen" rel="stylesheet" type="text/css" />
        <link href="http://(mydomain)/assets/snippets/calendar/templates/list/event-list.css" media="screen" rel="stylesheet" type="text/css" />

        You’ll want to change (mydomain) to your domain name, obviously.

        This fixed default, mini and list. (FYI, it displays the ical calendar, but nothing happens when you click the blue dates. This might be because I’m using Firefox.)

        Does anyone have any idea how much, if any, it slows down the page load to have multiple css calls? If it’s negligible, then this is a good fix.

        Elizabeth
          • 11055 ☆ A M B ☆
          • 3,112 Posts
          Quote from: enick5 at Nov 16, 2009, 04:48 PM

          This fixed default, mini and list. (FYI, it displays the ical calendar, but nothing happens when you click the blue dates. This might be because I’m using Firefox.)

          Does anyone have any idea how much, if any, it slows down the page load to have multiple css calls? If it’s negligible, then this is a good fix.

          Elizabeth

          Try call css inside the body section.
          It means, you don’t have to make a new template.

          Or, you can create a Template Variable (you may say it "template’s $variable" for easy reminder), to add the flexibility css call inside all Template.

          It just to avoid the useless css that apply globally.
            Rico
            Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
            MODx is great, but knowing how to use it well makes it perfect!

            www.virtudraft.com

            Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

            Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

            Maintainter/contributor of Babel

            Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
            • 4041
            • 788 Posts
            Although untested, the modified calendar.inc.php below (couldn’t attach a zip on this post) should fix this css issue... it uses the API to include only the relevent css when needed (the file is commented where the changes occur).

            First you will have to remove the first line of all the templates (the <link href=""> part) and then replace your exisiting calendar.inc.php with the code below (make a backup first!! lol).

            Someone give this a run through and see if it helps smiley
            <?php
            /* modified 5/31/09 */
            require_once($basePath.'classes/simplepie/simplepie.inc');
            require_once($basePath.'classes/class.simplepie-gcalendar.php');
            require_once($basePath.'classes/class.Calendar_Events.php');
            
            /* Snippet Parameters */
            $useModx             = (isset($useModx))                        ? $useModx                         : true;
            $emails              = (isset($emails))                   ? $emails                    : "[email protected]";
            $offset             = (isset($offset))                  ? $offset                   : "now";
            $order              = (isset($order))                   ? $order                    : true;
            $useCache           = (isset($useCache))                ? $useCache                 : true;
            $template           = (isset($template))                ? $template                 : 'default';
            $display            = (isset($display))                 ? $display                  : 'calendar';
            $limit              = (isset($limit))                   ? $limit                    : 10;
            $showPastEvents        = (isset($showPastEvents))  ? $showPastEvents   : true;
            /* end of Snippet Parameters */
            
            extract($_GET);    
            $year  = isset($_GET['year'])   ? $year     : date('Y');
            $month = isset($_GET['month'])  ? $month    : date('m');
            
            $startMin = gmdate('Y-m-d',mktime(0, 0, 0, gmdate($month)-2  , gmdate("d"), gmdate($year)));
            $startMax = gmdate('Y-m-d',mktime(0, 0, 0, gmdate($month)+2  , gmdate("d"), gmdate($year)));
            
            if (!$showPastEvents) {
                $startMin = date("Y-m-d");
            }
            
            /* Set URL to use */
            if ($useModx) {
                    /* Modx Site */
                    $docId             = $modx->documentIdentifier;
                    $this_page         = $modx->makeUrl($docId);
            
                    $url_arg        = '&';
                    if($modx->config['friendly_urls'] == 1) {
                              $arg = '?';
                    }
                    
                    $this_page .= $url_arg;
            } else {
                    /* Non-Modx Site */
                    $this_page = basename($_SERVER['REQUEST_URI']);
                    if (strpos($this_page, "?") !== false) $this_page = reset(explode("?", $this_page));
                    $this_page  = 'index.php';
                    $this_page .= '?';
            }
            
            $emails = explode(',', $emails);
            $urls         = array();
            foreach ($emails as $email){
                    $urls[] = trim(SimplePie_GCalendar::create_feed_url($email));
            }
            $feed = new SimplePie_GCalendar();
            
                /* GCalendar Parameters */
                $feed->set_show_past_events(1);
                $feed->set_sort_ascending(1);
                $feed->set_orderby_by_start_date(1);
                $feed->set_expand_single_events(1);
                $feed->set_start_min_date($startMin);
                $feed->set_start_max_date($startMax);
                $feed->set_max_results();
                $feed->set_cal_query();
            
                /* SimplePie Parameters */
                if ($useCache)
                $feed->set_cache_location($basePath . 'cache');
                else
                $feed->enable_cache(false);
                
                $feed->set_feed_url($urls);
                    $feed->enable_order_by_date(FALSE);
                    $feed->init();
                    $feed->handle_content_type();
                    $gcalendar_data = $feed->get_items();
                    
                    $cal_dates = array();
                    
                    for ($i = 0; $i < sizeof($gcalendar_data) ; $i++){
                    $item = $gcalendar_data[$i];
                            
                            $startDate = $item->get_start_time();
                            $endDate   = $item->get_end_time();
                            $calName   = $item->get_name();
                    $cal_dates[] = array(
                            'sortDate'  => $item->get_start_time(),
                            'startDate' => date("M j, y g:i", $startDate - $offset),
                            'endDate'   => date("M j, y g:i", $endDate - $offset),
                            'pubDate'   => date("M j, y g:i", $item->get_publish_date()),
                            'title'     => $item->get_title(),
                            'where'     => $item->get_location(),
                            'link'      => $item->get_link(),
                            'status'    => $item->get_status(),
                            'description' => $item->get_description(),
                            'startDay'      => date('j', $startDate - $offset),
                            'startMonth'    => date('n', $startDate - $offset),
                            'startYear'     => date('Y', $startDate - $offset),
                            'startHour'     => date('g', $startDate - $offset),
                            'startMinute'   => date('i', $startDate - $offset),
                            'startMeridiem' => date('A', $startDate - $offset),
                            'endDay'        => date('j', $endDate - $offset),
                            'endMonth'      => date('n', $endDate - $offset),
                            'endYear'       => date('Y', $endDate - $offset),
                            'endHour'       => date('g', $endDate - $offset),
                            'endMinute'     => date('i', $endDate - $offset),
                            'endMeridiem'   => date('A', $endDate - $offset),
                            'calName'                => $calName,
                            'calNameClean'        => str_replace(' ', '-', strtolower($calName)),
                            'calEmail'                => $item->get_email(),
                        );
                    }
            
            $feed->__destruct();
            unset($feed);
            /* end of SimplePie code */
            
            /* beginning of Sorting */
            if ($cal_dates)
            {
                $date = array();
                foreach ($cal_dates as $key => $row) {
                    $date[$key]  = $row['sortDate'];
                }
            
                if ($order)
                array_multisort($date, SORT_ASC, $cal_dates);
                else
                array_multisort($date, SORT_DESC, $cal_dates);
            }
            /* beginning of Sorting */
            
            /* Beginning of Calendar Output Code */
            if ($display == 'calendar')
            {
                $cal = new Calendar_Events ($year, $month);
                    /*Calendar Parser parameters */
                    $cal->setDayNameFormat('%a');
                    $cal->url = $this_page;
                    if ($template)
                    {
                        $cal->tpl['calendar']      = file_get_contents($basePath. 'templates/' .$template. '/calendar.tpl');
                        $cal->tpl['dayNoEvent']    = file_get_contents($basePath. 'templates/' .$template. '/dayNoEvent.tpl');
                        $cal->tpl['dayWithEvent']  = file_get_contents($basePath. 'templates/' .$template. '/dayWithEvent.tpl');
                        $cal->tpl['eachEvent']     = file_get_contents($basePath. 'templates/' .$template. '/eachEvent.tpl');
                        $cal->tpl['notInMonth']    = file_get_contents($basePath. 'templates/' .$template. '/notInMonth.tpl');
                    }
                
                    if ($cal_dates)
                    {
                
                        foreach ($cal_dates as $date)
                        {
                            if ($date['status'] != "canceled" && $date['startMonth'] == $month && strlen(trim($date['sortDate'])) > 0)
                            {
                                $cal->addEvent($date['startDay'], $date);
                            }
                        }
                        
                        #echo '<pre>';
                        #print_r($cal_dates);
                        #echo '</pre>';
                    }
            // 5/31/09  3:05 pm est
            // inject the proper stylesheet into the <head> section dynamically
            // requires removal of the first line of all templates which call the css (ical|mini|default)/calendar.tpl
                $modx->regClientCSS($basePath. 'templates/'.$template.'/calendar.css');
                    
                $output = $cal->display();
            }
            /* End of Calendar Output */
            
            /* Beginning of List Output */
            if ($display == 'list')
            {
                $tpl['wrapper']      = file_get_contents($basePath. 'templates/' .$template. '/wrapper.tpl');
                $tpl['eachEvent']    = file_get_contents($basePath. 'templates/' .$template. '/eachEvent.tpl');
                $tpl['eachEventAlt'] = file_get_contents($basePath. 'templates/' .$template. '/eachEventAlt.tpl');
            
                if ($cal_dates)
                {
                    $innerList = '';
                    for ($i = 0; $i < $limit; $i++)
                    {
                            if ($cal_dates[$i]['startMonth'] == $month )
                            {
                                if($i % 2) 
                                {
                                    $eachEvent = $tpl['eachEvent'];
                                } else {
                                    $eachEvent = $tpl['eachEventAlt'];
                                }
                                
                                foreach ($cal_dates[$i] as $key => $value)
                                {
                                    $eachEvent = str_replace('[+' . $key . '+]', $value, $eachEvent);
                                }
                                
                                $innerList .= $eachEvent;
                            }
                            
                    }
            // 5/31/09  3:05 pm est
            // inject the proper stylesheet into the <head> section dynamically
            // requires removal of the first line of templates/list/wrapper.tpl
                $modx->regClientCSS($basePath. 'templates/list/event-list.css');
                    
                    $output = str_replace('[+events+]', $innerList, $tpl['wrapper']);
                }
            
            }
            /* End of List Output */
            /*Do the Output */
            
            echo $output;
            ?>
              xforum
              http://frsbuilders.net (under construction) forum for evolution
              • 34017
              • 898 Posts
              thanks breezer. so simple.
                Chuck the Trukk
                ProWebscape.com :: Nashville-WebDesign.com
                - - - - - - - -
                What are TV's? Here's some info below.
                http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
                http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
                • 29201
                • 239 Posts
                Chuck,

                This is a great snippet. Thank you for your work.

                Can anyone tell me what the delay is on sync between Google Cal and modx calendar? Is there in fact a delay?

                I created one Google cal event which was viewable right away on the modx cal however the second event I’m not seeing. Also, it is not picking up updates to my first event.

                thanks,

                Eliot
                  • 34017
                  • 898 Posts
                  Eliot,

                  It’s probably the cache. And the cache is set to 60 minutes i believe by default.

                  You can either delete the files in the cache folder or set the cache parameter to false (i think it’s false, you can check the snippet to be sure).

                  Man Im too slammed =)
                    Chuck the Trukk
                    ProWebscape.com :: Nashville-WebDesign.com
                    - - - - - - - -
                    What are TV's? Here's some info below.
                    http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
                    http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
                    • 27731
                    • 9 Posts
                    I now got the formatting to work, thanks for the replies!

                    But, now the most fundamental thing does not work... I can’t get my "own" calendar to show! I only get a valid calendar if I DO NOT enter the $emails parameter in the snippet call.

                    So, this gives me the US holiday calendar:

                    [!Calendar? &offset=`-2 hours` &display=`calendar` &template=`default`!]


                    This also give me the US holiday calendar:

                    [!Calendar? &emails=`[email protected]` &offset=`-2 hours` &display=`calendar` &template=`default`!]

                    But this does not give anything:

                    [!Calendar? &emails=`en.swedish#[email protected]` &offset=`-2 hours` &display=`calendar` &template=`default`!]

                    This address (en.swedish#[email protected]) is addressable when playing around in Google Calendar. I’ve also tried with my test account ( [email protected]) but neither that works. Can anyone of you bring up this account in the snippet?

                    What am I doing wrong?
                      • 29201
                      • 239 Posts
                      smf,

                      have you made your calender public?

                      it should work with only the email addy that you used to setup your Google calendar. i too struggled with this a bit.....i wasn’t sure if I should use my email or the name of my calendar in the snippet.

                      eliot