|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Sedgar Smarty n00b
Joined: 07 Jul 2005 Posts: 4 Location: Ukraine
|
Posted: Thu Jul 07, 2005 9:14 am Post subject: {html_select_date} |
|
|
I needed some like this
{html_select_date css_class="inputdate" selected_day=$added[2] selected_month=$added[1] selected_year=$added[0] day_value_format="%02d" month_language="russian"}
So I modified function.html_select_date.php
Code: |
......
$selected_day = null;
$selected_month = null;
$selected_year = null;
$css_class = null;
$month_language = null;
foreach ($params as $_key=>$_value) {
switch ($_key) {
case 'month_language':
case 'css_class':
case 'selected_day':
case 'selected_month':
case 'selected_year':
case 'prefix':
............
// Now split this in pieces, which later can be used to set the select
$time = explode("-", $time);
if (null !== $selected_day)
$time[2]=$selected_day;
if (null !== $selected_month)
$time[1]=$selected_month;
if (null !== $selected_year)
$time[0]=$selected_year;
.................
if(isset($month_empty)) {
$month_names[''] = $month_empty;
$month_values[''] = '';
}
if ( null !== $month_language and (strtolower($month_language)==="russian") ) {
$month_names=array('Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь');
for ($i = 1; $i <= 12; $i++) {
$month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
}
}
else {
for ($i = 1; $i <= 12; $i++) {
$month_names[$i] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
$month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
}
}
.................
if (null !== $css_class){
$month_result .= ' class="' . $css_class . '"';
}
$month_result .= '>'."\n";
.... and so on for $day_result and $year_result.....
|
Is it correct? |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Thu Jul 07, 2005 12:37 pm Post subject: |
|
|
Hi,
most plugins parse the parameters which weren`t expected through to the html filed...
have a try:
Code: |
{html_select_date class="inputdate" selected_day=$added[2] selected_month=$added[1] selected_year=$added[0] day_value_format="%02d" month_language="russian"}
|
So you dont need a hack..
Bye,
Markus |
|
Back to top |
|
Sedgar Smarty n00b
Joined: 07 Jul 2005 Posts: 4 Location: Ukraine
|
Posted: Fri Jul 08, 2005 8:46 am Post subject: |
|
|
Most, but html_select_date don't ...?
This code has't any effect
Code: |
{html_select_date class="someclass" start_year="-5" end_year="+5" field_order="DMY"}
|
Result:
Code: |
<select name="Date_Day">
<option label="01" value="01">01</option>
................
<select name="Date_Month">
<option label="Январь" value="01">Январь</option>
................
<select name="Date_Year">
<option label="2000" value="2000">2000</option>
|
Expected
Code: |
<select name="Date_Day" class="someclass">
<option label="01" value="01">01</option>
................
<select name="Date_Month" class="someclass">
<option label="Январь" value="01">Январь</option>
................
<select name="Date_Year" class="someclass">
<option label="2000" value="2000">2000</option>
|
P.S. selected_day, selected_month, selected_year, month_language, css_class - implemented by me, is it so need to do it or exist other ways to do this functionality? |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Fri Jul 08, 2005 9:00 am Post subject: |
|
|
oh, so the plugin should be updated...to do this like all the others do...
But your solution only allows the use of the "class" attribute.
Every attribute you pass should be passed through to the tag..
Bye,
Markus |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Jul 08, 2005 1:37 pm Post subject: |
|
|
This is updated in CVS, give it a try. Any attibute will get passed through. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Fri Jul 08, 2005 1:57 pm Post subject: |
|
|
FWIW: we allready had month_extra, day_extra, year_extra and all_extra attributes to serve this purpose. |
|
Back to top |
|
Sedgar Smarty n00b
Joined: 07 Jul 2005 Posts: 4 Location: Ukraine
|
Posted: Tue Jul 12, 2005 8:34 am Post subject: |
|
|
Ok, *_extra attributes is good.
However, maybe this a silly question, but how I can mark specified option as selected with existent functionality?
Thanks.
(sorry for question that not corresponding to the topic) |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|