View previous topic :: View next topic |
Author |
Message |
cybot Smarty Regular
Joined: 20 Apr 2005 Posts: 83
|
Posted: Wed Apr 20, 2005 2:50 pm Post subject: html_select_date with option for a single selectbox |
|
|
it would be nice if html_select_date can be called like this:
{html_select_date start=$smarty.now order='reverse' count=5 single=true}
would produce something like this:
<option value="2005-04-11">2005-04-11</option>
<option value="2005-04-10">2005-04-10</option>
<option value="2005-04-09">2005-04-09</option>
<option value="2005-04-08">2005-04-08</option>
<option value="2005-04-07">2005-04-07</option> |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Apr 20, 2005 3:10 pm Post subject: |
|
|
You can't get them all in a single dropdown box (there would be WAY too many of them in many cases), you can supply your dates from PHP and use {html_options} to display them. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Apr 20, 2005 3:19 pm Post subject: |
|
|
Adding that feature wouldn't be easy, it really changes the behavior of the dropdown. What if you wanted this (by months, not days):
<option value="2005-04">2005-04</option>
<option value="2005-03">2005-03</option>
<option value="2005-02">2005-02</option>
or this (different format):
<option value="200504">Apr 2005</option>
<option value="200503">Mar 2005</option>
<option value="200502">Feb 2005</option> |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Apr 20, 2005 3:57 pm Post subject: |
|
|
It is hard to get around the fact that multiple html drop-downs are an expediant but rather clumsy way to provide date controls.
If you can afford javascript at your site and for your users, I find this to be very useful: http://www.phpinsider.com/smarty-forum/viewtopic.php?t=3853 |
|
Back to top |
|
cybot Smarty Regular
Joined: 20 Apr 2005 Posts: 83
|
Posted: Wed Apr 20, 2005 3:59 pm Post subject: |
|
|
mohrt wrote: | You can't get them all in a single dropdown box (there would be WAY too many of them in many cases), you can supply your dates from PHP and use {html_options} to display them. |
there should be a paramter 'start' and 'end' or 'count' |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Apr 20, 2005 4:07 pm Post subject: |
|
|
cybot wrote: | there should be a paramter 'start' and 'end' or 'count' |
All of the days and months are always shown. As for the year, you can already do that with start_year="-5", end_year="+5", etc. |
|
Back to top |
|
cybot Smarty Regular
Joined: 20 Apr 2005 Posts: 83
|
Posted: Wed Apr 20, 2005 4:08 pm Post subject: |
|
|
boots wrote: | It is hard to get around the fact that multiple html drop-downs are an expediant but rather clumsy way to provide date controls. |
normally, but i will only provide about ten dates, this is usefull for many things, for example a callback formular, there you need no dates which are weeks in the future
no, not rellay god, the app is good but WAI prevents me from using this! |
|
Back to top |
|
cybot Smarty Regular
Joined: 20 Apr 2005 Posts: 83
|
Posted: Wed Apr 20, 2005 4:10 pm Post subject: |
|
|
mohrt wrote: | All of the days and months are always shown. As for the year, you can already do that with start_year="-5", end_year="+5", etc. |
i know, but this doesnt helps me! |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Apr 20, 2005 4:23 pm Post subject: |
|
|
[php:1:652e611819]
$start_date = time();
$count = 5;
for($x=0; $x<$count; $x++) {
$smarty->append('dates', strftime("%Y-%m-%d", $start_date + 86400 * $x));
}
[/php:1:652e611819]
Code: | {html_options values=$dates output=$dates} |
you can control the format too:
Code: | {html_options values=$dates|date_format:"%Y%m%d" output=$dates|date_format:"%B %e, %Y"} |
|
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Apr 20, 2005 4:49 pm Post subject: |
|
|
cybot wrote: | the app is good but WAI prevents me from using this! |
hmmm....then the WAI is terribly broken. If tools that make things easier (and provide familiar metaphors) don't make interaction more accessible, I don't know what does. Then again, I don't recall the WAI explicitly saying that JS can't be used -- but rather that alternates must also be provided.
Anyway, this is just my little opinion, so fairly worthless since I mainly deliver my apps on intranets |
|
Back to top |
|
|