Home · Links · Contact Us
Home arrow Forums
Home
Features
FAQ
Screen Shots
Modules
Themes
Demos
Documentation
Forums
Contact Us
Download
Purchase
Quotes

" ... I want to tell you that your thyme product is functional and valuable beyond words. I cannot imagine why any portal would be without it. It is the cornerstone of our new project ..."

" ... Thanks for such a complete project, its making my job much easier. ..."

" ... I have now deployed 4 different calendars and our users love them ... "

" ... Easy to install and use and a great look/design. ..."

" ... This has to be the easiest to use program I think I've had to deal with at all this year. ..."


  FAQFAQ    SearchSearch  RegisterRegister   Log inLog in 
Limit get_event_list?

 
Post new topic   Reply to topic     Forum Index -> Web site integration
View previous topic :: View next topic  
Author Message
kiwi_dude



Joined: 05 Jun 2006
Posts: 25

PostPosted: Tue Jan 16, 2007 12:17 am    Post subject: Limit get_event_list? Reply with quote

Hi Ian,

I am using the $cal->get_event_list("day"); function to return the events on today.

Unfortuanately, I have some days that have upwards of 50 events happening. How can I limit the number of events that are returned (or displayed) for that day using this code ie 10, 15 etc?

This is the code I am using (provided by you Smile of course):

$elist = $cal->get_event_list("day");

// before anything ..
$events_printed = 0;

# each day returned in this list
foreach($elist as $d) {

# each event on this day
foreach($d as $e) {
$events_printed = 1;
# Get full event details
$e = $cal->get_event($e['id'],$e['instance']);

if ($e->notes == "") $notes = "No Details Given";

else $notes = $e->notes;

echo("id."&instance=2007-1-19&KeepThis=true&TB_iframe=true&height=300&width=500\">".$e->title."  ".$cal->format_date("D M j",$e->start).""
);

}
Back to top
View user's profile Send private message
esoft_kent



Joined: 11 Jan 2007
Posts: 143

PostPosted: Tue Jan 16, 2007 7:10 pm    Post subject: Reply with quote

You can limit the display by using a different type of for loop.

Change this:
Code:
# each day returned in this list
foreach($elist as $d) {

# each event on this day
foreach($d as $e) {
$events_printed = 1;
# Get full event details
$e = $cal->get_event($e['id'],$e['instance']);


to this (replace '15' with whatever max number you want):
Code:
# each day returned in this list
foreach($elist as $d) {

# each event on this day

for ($i = 0; $i < 15; $i++ ) {

$e = $d[$i];

$events_printed = 1;
# Get full event details
$e = $cal->get_event($e['id'],$e['instance']);


Kent

edit: There's more info on control loop structures here: http://us3.php.net/manual/en/control-structures.for.php
Back to top
View user's profile Send private message
kiwi_dude



Joined: 05 Jun 2006
Posts: 25

PostPosted: Tue Jan 16, 2007 10:27 pm    Post subject: Reply with quote

Hi Ken,

Thanks for the code, unfortunatley the 'for' loop doeas not work correcty in place of the 'foreach' loop in this circumstance (i get a large list of just "event" items - much longer than 15)

Any other ideas??

Cheers

Dean
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Tue Jan 16, 2007 10:50 pm    Post subject: Reply with quote

Hi,

Try:

Code:

$limit = 15;

# each day returned in this list
foreach($elist as $d) {

   if(!$limit) break;

   # each event on this day
   foreach($d as $e) {

      if(!$limit--) break;

      $events_printed = 1;
     # Get full event details
     $e = $cal->get_event($e['id'],$e['instance']);
Back to top
View user's profile Send private message Visit poster's website
kiwi_dude



Joined: 05 Jun 2006
Posts: 25

PostPosted: Wed Jan 17, 2007 1:00 am    Post subject: Reply with quote

Almost got it..

Code:

// before anything ..
$events_printed = 0;
$limit = 10;

# each day returned in this list
foreach($elist as $d) {

   if(!$limit) break;

   # each event on this day
   foreach($d as $e) {

      if(!$limit--) break

       $events_printed = 1;
       # Get full event details
       $e = $cal->get_event($e['id'],$e['instance']);
       
       # print event title
       //echo("title."&instance=2007-1-19\">".$e->title."");
     if ($e->notes == "") $notes = "No Details Given";
    
     else $notes = $e->notes;
    
     echo("id."&instance=".$e->instance."&KeepThis=true&TB_iframe=true&height=310&width=520\">".$e->title.""
      );
      
    }

}

if(!$events_printed ) {

    echo("No Upcoming Events (The Next 2 Weeks)");
    echo("Calendar...");

}

else {

    echo("More...");

}


This prints out 10 items. but also prints the "No Upcoming Events (The Next 2 Weeks)", even though $events_printed should equal 1?

Thanks for your assistance..much appreciated

Cheers
Back to top
View user's profile Send private message
esoft_kent



Joined: 11 Jan 2007
Posts: 143

PostPosted: Wed Jan 17, 2007 6:09 pm    Post subject: Reply with quote

Hmmm, guess I had something not quite right Smile.

Ian's code looks great, too - cleaner. Try putting a semicolon after the line
Code:
if(!$limit) break
so that it reads
Code:
if(!$limit) break;


That seemed to fix it for me.
Back to top
View user's profile Send private message
kiwi_dude



Joined: 05 Jun 2006
Posts: 25

PostPosted: Wed Jan 17, 2007 9:39 pm    Post subject: Reply with quote

Thanks Kent, all working Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Web site integration All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
© 2005 eXtrovert software unless otherwise noted. All rights reserved.
Portions © 2004 Ben Brown. All rights reserved.
Trademarks are property of their respective owners.