Welcome Guest, Not a member yet? Register   Sign In
Calendar - multiple articles on the same date?
#1

[eluser]Unknown[/eluser]
I'm very new to CI and facing a problem - need to show several articles in the calendar on the same day. (The tutorial - http://ellislab.com/codeigniter/user-gui...endar.html - shows only 1 event per date). Is that possible? Thanks.
#2

[eluser]Thorpe Obazee[/eluser]
You many need to extend the Calendar class.
#3

[eluser]Unknown[/eluser]
Yeah, everything was pretty easy Smile
If we pass an array like:
Code:
$data['events'] = array(
                        3  => array ("http://code.com/news/article/article-title-3-1", "http://code.com/news/article/article-title-3-2"),
                        7  => "http://code.com/news/article/article-title-07",
                        21 => "http://code.com/news/article/article-title-21",
                        30 => "http://code.com/news/article/article-title-30"
                      );
And a little modification in the Calendar class:
Code:
if (isset($data[$day]))
{    
  // Cells with content
  $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
  
  // If more than one event on the same day
  if (is_array($data[$day]))
  {
    $several_events = '';
    foreach ($data[$day] as $key => $value)
    {
      $several_events .= '<br /><a href="'.$value.'">'.$key.'</a>';
    }
    $out .= str_replace('{day}', $day, str_replace('<a href="{content}">{day}</a>', $day.$several_events, $temp));
  }

  // One event per day
  else
  {
    $out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp));
  }
}

Maybe it will help someone ;-)
#4

[eluser]janogarcia[/eluser]
Thanks, just in time! I needed to tackle the same issue today (I'll extend the CI_Calendar class instead of directly modifying it, though).
#5

[eluser]sophistry[/eluser]
see my sig for another approach to getting multiple events per day on a month calendar. i got annoyed at the wimpy CI calendar class one day so i built an object-oriented version to fix some of the problems.
#6

[eluser]janogarcia[/eluser]
Double thanks to sophistry! Can't believe it, I was searching too for an elegant way of loading static pages/sections, found some threads but not yours (the one about site_migrate).
#7

[eluser]Jagar[/eluser]
sophistry, is there any example(s) on how the calendar in your sig looks like?

Thanks
#8

[eluser]Jagar[/eluser]
zoltano, thanks for your provided solution, I'm using it and it's good, except I'm using xajax to go back and forth between month so if I do something like: $data = array(10=>array("Event 1"=>"http://www.example.com","event 2"=>"http://www.example2.net"); it will be displayed in all the months.

I've been looking for a way to specify the month as well in the array so it displays the event in the month and day specified.

the following how I use the calendar with xajax:

Code:
function _cal($get){
        $objR = new xajaxResponse();
        $year_month = split("/",$get);
        $data = array(
        15=>array("Event 1"=>site_url("event_detail/1")));
        
        
        $objR->assign("calendar","innerHTML",$this->calendar->generate($year_month[0],$year_month[1],$data));
        return $objR;
    }

Thanks
#9

[eluser]sophistry[/eluser]
[quote author="Jagar" date="1245102368"]sophistry, is there any example(s) on how the calendar in your sig looks like?
Thanks[/quote]

i don't have any example. in fact, i was just thinking of taking down that CSS file because it just complicates things. the OOCalendar is for developers who want to have an Object Oriented Calendar instead of the string-oriented one provided in the CI distribution.

cheers.
#10

[eluser]Jagar[/eluser]
zoltano, thanks to the modification you provided I can load multiple events in one day as follow:

Code:
$data[$day][$value['event_title']] = site_url('event_detail/'.$value['event_id']);

But those events will appear in every single month with the same day, I looking at doing something like this

Code:
$data[$year][$month][$day][$value['event_title']] = site_url('event_detail/'.$value['event_id']);

or

$data[$month][$day][$value['event_title']] = site_url('event_detail/'.$value['event_id']);

$month $day and $year are extracted from $event_date before those lines.

I can't figure out how to do the modification, and I know it is somewhere here:

Code:
if (isset($data[$day]))
                    {
                        // Cells with content
                        $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];

I would really appreciate if you could tell me how this can be done.

Thanks in advance




Theme © iAndrew 2016 - Forum software by © MyBB