CodeIgniter Forums
How to... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to... (/showthread.php?tid=13177)



How to... - El Forum - 11-13-2008

[eluser]frietkot[/eluser]
I saw this in the user guide:
Code:
$data = array(
               3  => 'http://example.com/news/article/2006/03/',
               7  => 'http://example.com/news/article/2006/07/',
               13 => 'http://example.com/news/article/2006/13/',
               26 => 'http://example.com/news/article/2006/26/'
             );

echo $this->calendar->generate(2006, 6, $data);

But it only shows you how to pass the days to the calendar, what if I want to pass a day, month and year to the calendar class.

How to do that?


How to... - El Forum - 11-16-2008

[eluser]frietkot[/eluser]
nobody knows?


How to... - El Forum - 11-16-2008

[eluser]davidbehler[/eluser]
Could describe your problem in detail?
Because actually you are passing year and month to the function in form of the first and second parameter.


How to... - El Forum - 11-16-2008

[eluser]frietkot[/eluser]
well, in the data array you only pass the days because the 3, 7 13 and 26 are always one the same day each month but i want to use the data array with days months and years something like this:

$data = array(
3-6-2008 => 'http://example.com/news/article/2006/03/',
7-5-2008 => 'http://example.com/news/article/2006/07/',
13-7-2009 => 'http://example.com/news/article/2006/13/',
26-9-2019 => 'http://example.com/news/article/2006/26/'
);


How to... - El Forum - 11-16-2008

[eluser]davidbehler[/eluser]
I haven't worked with the calendar library yet but can't you just do this
Code:
$data = array(
          3 => ‘http://example.com/news/article/2006/03/‘
        );
$this->calendar->generate(2008, 6, $data);

$data = array(
          7 => ‘http://example.com/news/article/2006/07/‘
        );
$this->calendar->generate(2008, 5, $data);

$data = array(
          13 => ‘http://example.com/news/article/2006/13/‘
        );
$this->calendar->generate(2009, 7, $data);

$data = array(
          26 => ‘http://example.com/news/article/2006/26/‘
        );
$this->calendar->generate(2019, 9, $data);
instead of passing a huge array that contains all your data?


How to... - El Forum - 11-16-2008

[eluser]Nick Husher[/eluser]
Code:
function addEventsToCalendar($events) {
    for($events as $eventKey=>$eventValue) {
        $eventDate = split('-',$eventKey);
        $eventYear = $eventDate[0];
        $eventMonth = $eventDate[1];
        $eventDay = (int)$eventDate[2];
        
        $calendarEntry = array($eventDay => $eventValue);
        
        $this->calendar->generate($eventYear, $eventMonth, $calendarEntry);
    }
}

addEventsToCalendar(array(
    '2008-11-1'=>'http://example.com/news/article/...',
    '2008-12-15'=>'http://example.com/news/article/...',
    '2008-12-20'=>'http://example.com/news/article/...'
));

The above code is untested, but I hope you can see where I'm going with it...