CodeIgniter Forums
Limit calendar events to display not working correct - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Limit calendar events to display not working correct (/showthread.php?tid=63937)



Limit calendar events to display not working correct - wolfgang1983 - 12-25-2015

I can add & view multiple calendar event on different days.

But if I have multiple dates shown it takes up to much room.

My question is how can I limit the number of events to show on that day.

I have tried $this->db->limit(2) but the only shows 2 on the whole calendar?

PHP Code:
   public function get_events($year$month) {
 
       $calendar = array();

 
       $this->db->where('year'$year);
 
       $this->db->where('month'$month);
 
       $query $this->db->get('events');

 
       $results $query->result_array();

 
       foreach ($results as $event) {

 
       if (array_key_exists($event['day'], $calendar)) {
     
                   
        $calendar
[$event['day']] = $calendar[$event['day']] .'
        <hr/>

           <div class="text-center">
        <span class="label label-info">New</span>
        </div>
        <br/>
        <div class="clearfix">
        <div class="pull-left">
        <ul class="list-unstyled text-center">
        <li >' 
        
word_limiter(anchor(base_url('report/events/'$year .'/'$month .'/?event_id='$event['events_id']), $event['event']), 4) . '
        </li>
        </ul>
        </div>
        <div class="pull-right">
        <form id="form-event" action="'
.base_url('dashboard/calendar').'" class="form-inline" method="post" enctype="multipart/form-data" onsubmit="return confirm(\'Are you sure you want to remove this!\')";>
        <input type="hidden" name="delete_id" value="'
.$event['events_id'].'">
        <a href="'
.base_url('report/events/edit' .'/?event_id='$event['events_id']).'" role="button" class="btn btn-primary"><i class="fa fa-pencil"></i></a>
        <button type"submit" class="btn btn-danger"><i class="fa fa-trash"></i></button>
        </form>
        </div>
        </div>'
;
     
               
        
} else {
     
               
        $calendar
[$event['day']] = '
        <div class="text-center">
        <span class="label label-info">New</span>
        </div>
        <br/>
        <div class="clearfix">
        <div class="pull-left">
        <ul class="list-unstyled text-center">
        <li >' 
        
word_limiter(anchor(base_url('report/events/'$year .'/'$month .'/?event_id='$event['events_id']), $event['event']), 4) . '
        </li>
        </ul>
        </div>
        <div class="pull-right">
        <form id="form-event" action="'
.base_url('dashboard/calendar').'" class="form-inline" method="post" enctype="multipart/form-data" onsubmit="return confirm(\'Are you sure you want to remove this!\')";>
        <input type="hidden" name="delete_id" value="'
.$event['events_id'].'">
        <a href="'
.base_url('report/events/edit' .'/?event_id='$event['events_id']).'" role="button" class="btn btn-primary"><i class="fa fa-pencil"></i></a>
        <button type"submit" class="btn btn-danger"><i class="fa fa-trash"></i></button>
        </form>
        </div>
        </div>
        '
;
     
   
        
}
     
    
        
}

 
       return $calendar;
 
   



RE: Limit calendar events to display not working correct - skunkbad - 12-25-2015

I've used the calendar quite a bit, and done a lot of customizing. I guess my question to you is, how can you just remove things from the calendar? You want to limit to 2 per day, so what happens to the others? I just wonder if you are heading down the wrong path. Perhaps the thing to do is to make the contents of the day smaller so more things fit. Maybe if you show the calendar, you could put the number of things for the day, and then when you click on them a modal pops up with the details. [Y/n]?


RE: Limit calendar events to display not working correct - wolfgang1983 - 12-25-2015

(12-25-2015, 06:45 PM)skunkbad Wrote: I've used the calendar quite a bit, and done a lot of customizing. I guess my question to you is, how can you just remove things from the calendar? You want to limit to 2 per day, so what happens to the others? I just wonder if you are heading down the wrong path. Perhaps the thing to do is to make the contents of the day smaller so more things fit. Maybe if you show the calendar, you could put the number of things for the day, and then when you click on them a modal pops up with the details. [Y/n]?

I prefer the contents the way the are at the moment.