Welcome Guest, Not a member yet? Register   Sign In
Just a suggestion about calendar!
#1

[eluser]Unknown[/eluser]
Hi there, don't know if this is the right forum but...

When passing data to calendar, like: (as in user guide)
Code:
3  => 'http://your-site.com/news/article/2006/03/' <-- WORK
03  => 'http://your-site.com/news/article/2006/03/', <-- DON'T WORK
Just because of leading zero! Smile
I spent about 20 min trying to figure out why wasn't working!

So, the suggestion is: data could be passed with or without leading zero!

Hugs from brazil!
Sry for bad english!
#2

[eluser]marcoss[/eluser]
[quote author="Xupisco" date="1182716121"]Hi there, don't know if this is the right forum but...

When passing data to calendar, like: (as in user guide)
Code:
3  => 'http://your-site.com/news/article/2006/03/' <-- WORK
03  => 'http://your-site.com/news/article/2006/03/', <-- DON'T WORK
Just because of leading zero! Smile
I spent about 20 min trying to figure out why wasn't working!

So, the suggestion is: data could be passed with or without leading zero!

Hugs from brazil!
Sry for bad english![/quote]

Use typecasting Wink

Code:
$array = array(3,03,'03');

    foreach ($array as $n) {
        print (int) $n.'<br/>';
    }

    //will print    
    3
    3
    3
#3

[eluser]thachp[/eluser]
^ cool. Thanks
#4

[eluser]sophistry[/eluser]
actually, the calendar class should be the one typecasting, but it doesn't. it assumes numeric array keys are passed to it but doesn't do anything to assure itself that they are numeric. the calendar class is pretty weak as it stands right now - good for quick, basic stuff but not good for a full calendar interface. that is, don't build a calendar interface around the CI calendar class - you will be sorry.

a few things:
&bull; the calendar items are set in an associative array with the day number of the month as the key and a string as data:
Code:
// line 223 shows the $data array being accessed by a numerical
// key inside a while loop driven by an incrementor and string replaced into a template
$out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp));

the least tiny change in the calendar class would help avoid making the developer typecast because of the internal design decisions of the calendar class creator. so, something like this would be a little help:
Code:
// since we are going to use the numerical incrementor as a key
// we typecast the key in case dev used zero padded string (or other "almost" number as their key
$out .= str_replace('{day}', $day, str_replace('{content}', $data[(int)$day], $temp));

&bull; the calendar does not support days before the start of the current month or days at the end of the month (e.g., sunday the last day of the previous month when the current month starts on a monday OR saturday the 1st of the next month when the current month ends on a friday).

&bull; cannot handle additonal URI segments when using next and prev functions. e.g, if you want to page through months but maintain a "filter" (say a category filter for blog posts) in the URI like domain.com/calendar/2006/03/dogs. it works on the month that is in the original URI but the auto-generated calendar month pager links do not have the additional "dogs" URI segment. this forces you to maintain simple things like that in sessions.

anyhow, enough complaining. good luck on your project.




Theme © iAndrew 2016 - Forum software by © MyBB