Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts

    Question show days(dates) on screen

    the following function brings back all events in my google calendar between 2 dates (which I have set manually) 2 weeks from today

    I would like to write out each day even if it does have an event

    at the moment it only writes out a line with an event
    PHP Code:

    function outputCalendarByDateRange($client$startDate='2007-05-01'
                                       
    $endDate='2007-08-01'
    {
      
    $gdataCal = new Zend_Gdata_Calendar($client);
      
    $query $gdataCal->newEventQuery();
      
    $query->setUser('default');
      
    $query->setVisibility('private');
      
    $query->setProjection('full');
      
    $query->setOrderby('starttime');
      
    $query->setStartMin($startDate);
      
    $query->setStartMax($endDate);
      
    $eventFeed $gdataCal->getCalendarEventFeed($query);
      echo 
    "<ul>\n";
      foreach (
    $eventFeed as $event) {
        echo 
    "\t<li>" $event->title->text .  " (" $event->id->text ")\n";
        echo 
    "\t\t<ul>\n";
        foreach (
    $event->when as $when) {
          echo 
    "\t\t\t<li>Starts: " $when->startTime "</li>\n";
        }
        echo 
    "\t\t</ul>\n";
        echo 
    "\t</li>\n";
      }
      echo 
    "</ul>\n";
    }


    echo 
    outputCalendarByDateRange($client'2011-05-23''2011-06-06'); 

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Wait... do you mean you want to write the date even if it DOESN'T have an event? Basically display a 2 week itinerary, showing the events on each date (showing nothing if there are no events)?

    If so, then you need to first sort the events' data into arrays, loop through the days, and check if the array contains any events on that day, displaying each day as you go. You'd probably want to use something like creating 2 arrays: one with all the data (ie, store each event object as an element in an array), and one array that contains the data's key in array 1 associated to the date of the event. So then you can use array_keys to search array 2 for the dates, getting back the appropriate keys pointing to the events in array 1, looping through those to get all the events on that day.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •