CodeIgniter Forums
calendar specific date - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: calendar specific date (/showthread.php?tid=37550)



calendar specific date - El Forum - 01-13-2011

[eluser]Mutsop[/eluser]
Hi,

I recently came across the following wiki page: [specific date]

Now how is it possible to use this dynamicly?

As in my controller i use this:
Code:
$list = $this->news_model->get_list()->result();

and for each list as item I could use
Code:
$item->date
to get the specific datetime.

But I don't get how to bring these 2 codes together...

Any ideas? Or maybe other work arounds?


calendar specific date - El Forum - 01-14-2011

[eluser]Mutsop[/eluser]
Anyone able to help me on this? Smile


calendar specific date - El Forum - 01-14-2011

[eluser]Cristian Gilè[/eluser]
Code:
$list = $this->news_model->get_list()->result();

$cal = array();

foreach($list as $item)
{
  $year = date('Y',$item->date); //I assume that you have stored the news date as int in your db
  $month = date('m',$item->date);
  $day = date('d',$item->date);
  
  $cal[$year][$month][$day] = $item->news_text;
}

$data['calendar'] = $this->calendar->generate('','',$cal); //pass this to your view

Change $item->date and $item->news_text according to your db fields.

Cristian Gilè


calendar specific date - El Forum - 01-14-2011

[eluser]Mutsop[/eluser]
Well I didn't store the date as int, but I can reformat it and convert to int, no? Big Grin

Thanks thought this is amazing!


calendar specific date - El Forum - 01-14-2011

[eluser]Cristian Gilè[/eluser]
Yes, you can. I generally prefer to store date as INT because is much easier to work with but this is only my opinion.
There is an open thread about the best way to store the date and time:
http://ellislab.com/forums/viewthread/177759/

Cristian Gilè


calendar specific date - El Forum - 01-14-2011

[eluser]Mutsop[/eluser]
Well it works like a charm... I do have one last question
In each filled in date, there is a dot that is added to the text

check:
http://www.scripttesting.com/evastienen/team/kalender_nationale

For some reason I can't seem to find where to remove the dot.


calendar specific date - El Forum - 01-14-2011

[eluser]Cristian Gilè[/eluser]
Check the calendar template (if any) for some random dot.

Cristian Gilè


calendar specific date - El Forum - 01-14-2011

[eluser]Mutsop[/eluser]
Woops forgot my calendar config file Big Grin