We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1330
    • 79 Posts
    Im also getting some PHX code when I go to the next month.
    I’ve got the month to change font etc. but now the code is showing up. Quite a bugger this is being.
    And Pixel I found out how to get the events to pop up in a new window.
    <a href="[+url+]" target="_blank" >[+title+]</a>

    Is the one I am using now, allows you to set hight and with of window as well as options.
    http://www.dynamicdrive.com/dynamicindex8/popwin.htm
      • 34017
      • 898 Posts
      You may want to change the tpl-Event-Heading to a table. It might be easier to work with:
      <tr id="navigation">
          <td colspan="2">
              <a class="previous" href="[+PreviousLink+]"><span>Previous Month</span></a>
          </td>
          <td colspan="3" class="monthname">
              [+FullMonthName+]
          </td>
          <td colspan="2">
              <a class="next" href="[+NextLink+]"><span>Next Month</span></a>
          </td>
      </tr>
      

        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
        • 1774
        • 34 Posts
        I’ve made some modifications to this snippet if anyone is interested.

        1. Most notably I’ve changed the &email parameter to &calAddress. This allows the snippet to support private calendars. Using the modified snippet you simply grab the XML url of your calendar (which is found at the bottom of the calendar details tab in your Google calendar settings) and past it into the &calAddress parameter. Multiple addresses can be separated by commas.

        2. I’ve also added a &cacheDuration parameter to allow users to easily change the default cache duration of simple pie. If you don’t want to wait 60 minutes for your calendar’s feed to be reread set this to something smaller. The time is in seconds so, &cacheDuration=`30` would make the cache only last for 30 seconds (great for testing... useless for deployment: try something more like &cacheDuration=`900`, which is 15minutes.)

        Here’s the updated snippet code:
        <?php
        // Resource Name: GoogleEvents
        // Author: Jesse Rochman
        // Forum Alias: Jesse R.
        // Version: 1.4.2
        // Compatible with .961
        // Released: 1/9/2007
        // Modified: 3/1/2007 by KyleJ
        // Modified: 3/2/2007 by Jesse
        //Modified: 11/19/2007 by Jesse
        //Modified: 1/9/2008 by Jesse
        //Modified: 12/18/2008 by Brandon Booth ([email protected]) added &cacheDuration parameter to allow setting of the cache duration. Defaults to 30 minutes 
        //               Changed &email parameter to &calAddress parameter so that private addresses could be accessed. Instead of putting your email address in
        //                Now you insert the full address of your calendar. This is found in the calendar details tab of your calendar settings. Simply click on the XML button
        //                 of either your public or private calendar address near the bottom. Copy the url and past it into this variable. Multiple addresses can be separated by commas (,)
        // Inspired by James Cridlands Google Calendar Code
        //Calendar Class is from Giorgos Tsiledakis Active Calendar
        
        $basePath = $modx->config['base_path'];
        $siteURL = $modx->config['site_url'];
        
        //Set your google calendar address
        $calAddress = isset($calAddress)? $calAddress : '';
        
        
        //Set month and day names.  You can translate here.
        $dayNames1 = array('S','M','T','W','T','F','S');
        $dayNames3 = array('Sun','Mon','Tue','Wed','Thur','Fri','Sat');
        $dayNamesFull = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
        $monthNames = array('January','February','March','April','May','June','July','August','September','October','November','December');
        
        if (!isset ($dayNameSize)) {
        	$dayNameSize = $dayNames3;
        	} elseif (strtolower($dayNameSize) == 'full') {
        	$dayNameSize = $dayNamesFull;
        	} elseif ($dayNameSize == 1) {
        	$dayNameSize = $dayNames1;
        	} else {
        	$dayNameSize = $dayNames3;
        	}
        
        //This will determine whether to output the calendar, the list, or both.
        $outputType = isset($outputType)? $outputType : "both";
        
        
        if(isset($gInternational) && $gInternational) {
        	$dateFormat = isset($dateFormat)? $dateFormat : "%D"; // mm/dd/yy see http://us2.php.net/strftime for details.
        	$timeFormat = isset($timeFormat)? $timeFormat : "%T";
        } else {
        	// Format for date and time
        	$dateFormat = isset($dateFormat)? $dateFormat : "l, F, jS, Y"; // Thursday, 10 March - see http://www.php.net/date for details
        	$timeFormat = isset($timeFormat)? $timeFormat : "g:ia";
        
        }
        
        //Order of Output.  True for Reverse Chronilogical and False for Chronilogical
        $order = isset($order)? $order : 'a';
        
        //Show Events For This Many Days Out
        $lastEvent = isset($lastEvent)? $lastEvent : 30;
        
        //Show only this many events
        $maxEvents = isset($maxEvents)? $maxEvents : 30;
        
        //Skip this many events.  This way you can make two snippet calls and jump around
        $skipEvents = isset($skipEvents)? $skipEvents : 0;
        
        // Cache location for your XML file
        $cache_location= $basePath.'assets/snippets/GoogleEvents/cache';
        
        // Here is where your copy of Simplepie lives
        require_once ($basePath.'assets/snippets/GoogleEvents/php/simplepie.inc');
        
        // Here is where included functions get added
        include_once ($basePath.'assets/snippets/GoogleEvents/includes/GoogleEvents.inc.php');
        
        //Sets a big or small calendar
        $calendarType = isset($calendarType)? $calendarType : '';
        
        //Determine the first day of the week
        $firstDay = isset($firstDay)? $firstDay : 0;
        
        // Change this to 'true' to see some debug code
        $debug = isset($debug)? $debug : 0;
        
        $cacheDuration = isset($cacheDuration) ? $cacheDuration : '1800';
        //Config ends
        
        //Template if the feed is empty or unavailable
        $tplEmpty = isset($tplEmpty)? $modx->getChunk($tplEmpty) : "<p>The feed is unavailable.  This could be caused by the server being down, an incorrect feed address, all your events are in the past, or if you have no events in your feed.</p>";
        
        
        if ($outputType == 'calendar' || $outputType == 'both') {
        	include_once('assets/snippets/GoogleEvents/source/activecalendar.php');
        	//For the calendar script
        	//Variables for Calendar
        	$myurl='?id='.$modx->documentIdentifier; // the links url is this page
        	$yearID=false; // init false to display current year
        	$monthID=false; // init false to display current month
        	$dayID=false; // init false to display current day
        	extract($_GET); // get the new values (if any) of $yearID,$monthID,$dayID
        	$arrowBack="<img src=\"assets/snippets/GoogleEvents/data/img/back.png\" alt=\"<<\" />"; // use png arrow back
        	$arrowForw="<img src=\"assets/snippets/GoogleEvents/data/img/forward.png\" alt=\">>\" />"; // use png arrow forward
        	$cal = new activeCalendar($yearID,$monthID,$dayID);
        }
        
        if ($outputType == 'list' || $outputType == 'both') {	
        	//Grab the templates.  If one isn't passed to the program, then setup a default template.
        	$defaultTemplate = '<div><h2><a href="[+linkURL+]">[+title+]</a></h2><p>[+startDate+] at [+startTime+]<br />Description: [+content+]</p></div>';
        	$numberOfEvents = 0;
        	$tpl = $modx->getChunk($tpl);
        	$tplOddRow = $modx->getChunk($tplOddRow);
        	$tplEvenRow = $modx->getChunk($tplEvenRow);
        	$tplFirstRow = $modx->getChunk($tplFirstRow);
        	$tplLastRow = $modx->getChunk($tplLastRow);
        
        	if ($tpl) {
        	  $defaultTemplate = $tpl;
        	}
        	if (!$tplOddRow) {
        	  $tplOddRow = $defaultTemplate;
        	}
        	if (!$tplEvenRow) {
        	  $tplEvenRow = $defaultTemplate;
        	}
        	if (!$tplFirstRow) {
        	  $tplFirstRow = $defaultTemplate;
        	}
        	if (!$tplLastRow) {
        	  $tplLastRow = $defaultTemplate;
        	}
        }
        
        $startMax = date('Y-m-d',mktime(0, 0, 0, date("m")  , date("d")+$lastEvent, date("Y")));
        
        $calAddresses = explode(',',$calAddress);
        $tempCounter = 0;
        $addresses = array();
        foreach ($calAddresses as $addy) {
        	//replace 'basic' at the end of all google cal feeds with 'full' so that the formatting string will work.
        	$addy = substr_replace($addy,'full',-5,5);
        	$addresses[$tempCounter] = $addy."?start-min=".date("Y-m-d").'&start-max='.$startMax."&orderby=starttime&sortorder=$order&singleevents=true";
        	$addressDebug .= '<a href="' . $addresses[$tempCounter] . '">' . $addresses[$tempCounter] . '</a> ';
        	$tempCounter++;
        	}
        
        //Template if the feed is empty or unavailable
        $emptyTpl = $modx->getChunk($tplEmpty);
        echo $emptyTpl;
        if (!$tplEmpty) $tplEmpty = "<p>The feed is unavailable.  This could be caused by the server being down, an incorrect feed address, all your events are in the past, or if you have no events in your feed. The feed(s) you tried to access include: $addressDebug</p>";
        	
        $feed = new SimplePie();
        
        if ($debug) {
        	echo "<p>Debug mode is on.</p>";
        	foreach ($addresses as $address) {
        		echo "<p>Getting <a href='$address'>XML feed</a></p>";
        		}
        	$feed->enable_cache(false);
        }
        
        $feed->set_feed_url($addresses);
        $feed->set_cache_location($cache_location);
        $feed->set_cache_duration($cacheDuration);
        $feed->enable_order_by_date(false);
        $feed->init();
        $feed->handle_content_type();
        $temp = array();
        
        if($feed->get_items()) {
        	foreach($feed->get_items() as $item) {	
        			 // We want to grab the Google-namespaced <gd:when> tag.
        			$when = $item->get_item_tags('http://schemas.google.com/g/2005', 'when');
        
        			// Once we grab the tag, let's parse it.
        			$startDate = $when[0]['attribs']['']['startTime'];
        			$sortDate = getGoogleDate($startDate);
        			if(isset($gInternational) && $gInternational) {
        				$startDate = strftime($dateFormat,$sortDate);
        				$startTime = strftime($timeFormat, $sortDate);
        				} else {
        				$startDate = date($dateFormat,$sortDate);
        				$startTime = date($timeFormat, $sortDate);
        				}
        			$startYear = date('Y',$sortDate);
        			$startMonth = date('n',$sortDate);
        			$startDay = date('j',$sortDate);
        			$endDate = $when[0]['attribs']['']['endTime'];
        			$tempEndDate = getGoogleDate($endDate);
        			if(isset($gInternational) && $gInternational) {
        				$endDate = strftime($dateFormat,$tempEndDate);
        				$endTime = strftime($timeFormat, $tempEndDate);
        				} else {
        				$endDate = date($dateFormat,$tempEndDate);
        				$endTime = date($timeFormat, $tempEndDate);
        				}
        				
        			// Now, let's grab the Google-namespaced <gd:where> tag.
        			$gd_where = $item->get_item_tags('http://schemas.google.com/g/2005', 'where');
        			$where = $gd_where[0]['attribs']['']['valueString'];
        
        			// Extract the "Event Description" information from the item summary, and ignore everything else
        			$eventDescription = $item->get_description();
        			
        			// Extract the link for Google Calendar
        			$url=$item->get_link();
        			
        			if ($debug) { 
        				echo "
        					  <p><b>Parsed Date:</b><br />
        					  Starting Day: $startDate<br />
        					  Starting Time: $startTime<br />
        					  Ending Day: $endDate<br />
        					  Ending Time: $endTime<br />
        					  Time Greater Than 0? $sortDate<br />
        					  Description: $eventDescription<br />
        					  URL:<a href=$url>$url</a></p>";
        					 }
        
        			// Stick into a nice array if it has a valid timestamp (not a recurring event).
        			$events[]=array('time'=>$sortDate,'where'=>$where,'title'=>$item->get_title(),'url'=>$url,'eventDescription'=>$eventDescription,'startDate'=>$startDate,'startTime'=>$startTime,'endDate'=>$endDate,'endTime'=>$endTime,'startYear'=>$startYear,'startDay'=>$startDay,'startMonthCal'=>$startMonth,'endTimeStamp'=>$tempEndDate);
        		}
        	
        	// Sort the bookings into time order
        	if ($order != "d"){
        	// Sort the events into chronilogical order.
        		sort($events);
        		} else {
        		rsort($events);
        		}
        	
        	$counterMaxEvents = 0;
        	$counterSkipEvents = 0;
        	foreach($events as $event) {
        		if ($outputType == 'list' || $outputType == 'both') {
        			$numberOfEvents++;
        			if ($counterSkipEvents >= $skipEvents){
        				//Figure out what template to use
        				if($numberOfEvents == 1 || $counterSkipEvents == $skipEvents) {
        					$template = $tplFirstRow;
        					} elseif ($numberOfEvents == count($events) || $counterMaxEvents == ($maxEvents-1)) {
        					$template = $tplLastRow;
        					} elseif (($numberOfEvents & 1) == 0) {
        					$template = $tplEvenRow;
        					} else {
        					$template = $tplOddRow;
        					}
        				$counterSkipEvents++;
        				//Output the data in the appropriate template
        				if ($counterMaxEvents < $maxEvents) {
        					$output = str_replace('[+title+]',$event['title'],$template);
        					$output = str_replace('[+startDate+]',$event['startDate'],$output);
        					$output = str_replace('[+startTime+]',$event['startTime'],$output);
        					$output = str_replace('[+endDate+]',$event['endDate'],$output);
        					$output = str_replace('[+endTime+]',$event['endTime'],$output);
        					$output = str_replace('[+where+]',$event['where'],$output);
        					$output = str_replace('[+content+]',$event['eventDescription'],$output);
        					$output = str_replace('[+eventNumber+]',$numberOfEvents,$output);
        					$output = str_replace('[+linkURL+]',$event['url'],$output);
        					$output = str_replace('[+sTimestamp+]',$event['time'],$output);
        					$output = str_replace('[+eTimestamp+]',$event['endTimeStamp'],$output);
        					echo $output;
        					$counterMaxEvents++;
        					} 
        			} else { 
        				$counterSkipEvents++;
        				}
        			} 
        			if($outputType == 'calendar' || $outputType == 'both') {
        				$cal->setEvent($event['startYear'],$event['startMonthCal'],$event['startDay'],"event",$event['url']);
        				if($calendarType == 'wide') {
        					$multipleLinesEvent=array($event['title'],$event['startTime'].'-'.$event['endTime']);
        					$cal->setEventContent($event['startYear'],$event['startMonthCal'],$event['startDay'],$multipleLinesEvent,$event['url']);
        				}
        			}
        	}	
        	if($outputType == 'calendar' || $outputType == 'both') {
        			//outPutCalendar($fullMonths, $shortMonths,$mDays, $arrangedEvents);
        			$cal->setDayNames($dayNameSize);
        			$cal->setMonthNames($monthNames);
        			$cal->setFirstWeekDay($firstDay);
        			$cal->enableMonthNav($myurl,$arrowBack,$arrowForw); // enables navigation controls
        			print $cal->showMonth();
        	}
        
        	return '';
        	} else {
        	return $tplEmpty;
        	}
        ?>
        
          Brandon Booth
          Freelance MODx specialist for hire: site construction, template conversion, snippet customization.
          Lucidgreen.net Websites made simple.
          • 29554
          • 3 Posts
          Hello,

          As a noob to ModX and GE I need some help - how does one get the events to appear in a pop up window; and where does the code go exactly? Some sort of step-by-step guide might be helpful. I know this might be a lot to ask but I would appreciate it. Thanks.

          Cheers,
          Michael
            • 1774
            • 34 Posts
            The instructions for installing the GCal snippet are in the readme file which is included with the files you downloaded from the repository. It should give you enough detailed info so that you at least get the snippet installed. But here is a little run down that may help.

            First, be sure that you run the compatibility test as the readme instructs.

            After that, upload the files contained in the download to a new folder you create: /assets/snippets/GoogleEvents

            Then:
            1. From the manager select the "Resources" tab and then "Manage Resources"
            2. Select "Snippets" tab > "new snippet"
            3. Copy and paste the code in GoogleEvents.php into a new snippet called "GoogleEvents". Make sure you only have one set of <?php ?> tags.

            Now the snippet is installed.

            To actually use it you need to insert the code [!GoogleEvents? &parameter=`value`!] In the page where you want the events to show.

            To make them pop up in a new window it is probably easiest to make a new document whose content is set to the snippet call you want. Just type the snippet call directly into the content area.

            Then create links to that document whose targets are set to _blank. You can do this easily with the rich text content manager. The link button in the rich text editor (it looks like a little chain) will let you select other documents in your document tree as the destination via the "link list" drop down set the target to "new window"). The "popup" tab in in that window will even let you set the dimensions of your pop up window.

            Hope that helps!
              Brandon Booth
              Freelance MODx specialist for hire: site construction, template conversion, snippet customization.
              Lucidgreen.net Websites made simple.
              • 29554
              • 3 Posts
              Hi Anselm,

              I managed to get the calendar to work, thanks.

              Will the last part of your instructions open an event from the calendar in a pop up window? I’m probably missing something but right now any event I click on opens in a new page that is full size.

              Cheers,
              Michael
                • 1774
                • 34 Posts
                TestZero,

                I guess I misunderstood your original question. To make the links to individual links to events create popup windows you will need to create your own template.

                The simplest way to do this is to create a chunk, name it anything you like, "gcalTpl" for example, and then create your template. the following should work,
                <div> 
                     <h2><a href="[+linkURL+]" target="_blank">[+title+]</a></h2> 
                     <p>[+startDate+] at [+startTime+]<br />Description: [+content+]</p>
                </div>
                


                If you need to resize the window you’ll have to need to use some javascript. The code could easily be used in the template above. Just add the <script> section above the <div> tag.

                finally add a parameter to your GoogleCalendar snippet call, like this:

                [!GoogleEvents? &tpl=`gcalTpl` &yourOtherParameters=`values`!]
                

                  Brandon Booth
                  Freelance MODx specialist for hire: site construction, template conversion, snippet customization.
                  Lucidgreen.net Websites made simple.
                  • 29554
                  • 3 Posts
                  Thank you very much anselm. I’ll try it out soon.

                  Cheers,
                  TZ
                    • 26425
                    • 15 Posts
                    Help!

                    bit of a ModX noob here. i’m using GoogleEvents i downloaded in nov 2008. i had it configured correctly before and it seemed to work.

                    now i go to the page where i have the GoogleEvents snippet called for my calendar and i get this PHP error:

                    MODx encountered the following error while attempting to parse the requested resource:
                    « PHP Parse Error »

                    PHP error debug
                    Error: require_once(/home/ilahjarv/public_html/scottrlooney/assets/snippets/GoogleEvents/php/simplepie.inc) [function.require-once]: failed to open stream: Permission denied
                    Error type/ Nr.: Warning - 2
                    File: /home/ilahjarv/public_html/scottrlooney/manager/includes/document.parser.class.inc.php(769) : eval()’d code
                    Line: 59

                    something tells me this not a fatal error - perhaps a permissions issue? i’m pretty sure the calendar in question works...

                    here’s the snippet call to GoogleEvents:

                    [!GoogleEvents?dayNameSize=`1`&outputType=`list`&maxEvents=`20`&tplFirstRow=`GoogleEvents`&email=`[email protected]`&tplOddRow=`GoogleEventsOdd`&tplEvenRow=`GoogleEventsEven`&tplLastRow=`GoogleEventsLast`&order=`a`!]

                    not sure what’s going on here - a little help for a newbie? have verified access to calendar with google calendar and identifier code is exactly the same as far as i’m aware.

                    any help appreciated,

                    thanks,

                    scott



                      • 1774
                      • 34 Posts
                      It does appear to be a permissions issue. check the permissions on your files uploaded to /assets/snippets/GoogleEvents. Any good ftp program will allow you to "chmod" the files to something readable, 644 should be sufficient.
                        Brandon Booth
                        Freelance MODx specialist for hire: site construction, template conversion, snippet customization.
                        Lucidgreen.net Websites made simple.